Skip to content

Commit

Permalink
update of version
Browse files Browse the repository at this point in the history
  • Loading branch information
rlunaro committed Nov 13, 2022
1 parent 1e68826 commit 9858fae
Show file tree
Hide file tree
Showing 32 changed files with 278 additions and 77 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ NOTES.html
SECRETS.md
SECRETS.html
PRIVATE/
site/
data/


.project
.pydevproject
Expand Down
File renamed without changes.
20 changes: 0 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,4 @@ google-drive-backup keeps a yearly, monthly and daily different copies
of your data, so it will be difficult to lose a file even if you realize
the lose time after.

## Installation procedure

To install google-drive-backup, follow this steps:

1. First of all, you have to request permission from google to use their API's. For instructions,
[clic here](docs/request_permission_from_google.md)
1. In the machine you want to run it, a working installation of python must be
in place. You can download it from https://www.python.org/
2. Install the needed google libraries by running:
`pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib oauth2client file_cache`
If you want to create a virtual environment using `virtualenv`, feel free to do so
3. Create a directory (for instance, google-drive-backup) and uncompress the
file "google-drive-backup-1.0.0.zip" into it
3. Configure the file config.json (you can start by renaming the file example-config.json)
(you don't need to modify the fifth section)
4. Configure the file google-drive-backup.bat if needed (specific instructions for users of virtualenv)
5. Run the bat file "google-drive-backup.bat" to test if everything works properly
6. Program in the task scheduler (or cron job) the corresponding execution of the batch file



6 changes: 3 additions & 3 deletions deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import datetime

lib_dir='/home/rluna/python/google-drive-backup-env/lib/python3.6/site-packages'
deployment_filename = 'google-drive-backup.zip'
deployment_filename = 'drive-backup.zip'

def add_file_dir( zipfile:object, file_path:str, archive_name:str ) -> None :
#print(f"Adding file {file_path}")
Expand Down Expand Up @@ -62,8 +62,8 @@ def add_file_dir( zipfile:object, file_path:str, archive_name:str ) -> None :
add_file_dir( deployment, 'example-config.json', 'example-config.json' )
add_file_dir( deployment, 'logging.json', 'logging.json' )

add_file_dir( deployment, 'google-drive-backup.bat', 'google-drive-backup.bat' )
add_file_dir( deployment, 'google-drive-backup.sh', 'google-drive-backup.sh' )
add_file_dir( deployment, 'drive-backup.cmd', 'drive-backup.cmd' )
add_file_dir( deployment, 'drive-backup.sh', 'drive-backup.sh' )

print(f'Deployed file {deployment_filename} on {datetime.datetime.now()}')

Expand Down
Binary file added docs/favicon.ico
Binary file not shown.
Binary file added docs/img/app-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/oauth_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/oauth_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/oauth_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/img/request01.png
Binary file not shown.
Binary file removed docs/img/request02.png
Binary file not shown.
Binary file removed docs/img/request03.png
Binary file not shown.
Binary file removed docs/img/request04.png
Binary file not shown.
Binary file removed docs/img/request05.png
Binary file not shown.
Binary file removed docs/img/request06.png
Binary file not shown.
Binary file removed docs/img/request07.png
Binary file not shown.
Binary file removed docs/img/request08.png
Binary file not shown.
Binary file removed docs/img/request09.png
Binary file not shown.
Binary file removed docs/img/request10.png
Binary file not shown.
Binary file removed docs/img/request11.png
Binary file not shown.
14 changes: 14 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# ![google-drive-backup logo](img/app-logo.png) Make backup copies to google drive

google-drive-backup is a python script that allows you to make a copy of
a single file or directory to google drive.

google-drive-backup keeps a yearly, monthly and daily different copies
of your data, so it will be difficult to lose a file even if you realize
the lose time after.

After finishing the backup it sends a email to keep yo informed on how
the copies went, for easy monitorization.


150 changes: 150 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@

# Installation procedure

## Python

[Python](https://www.python.org) version 3 must be installed to
make this application work.

Once you have python installed, I recommend to setup a virtual
environment to make this drive-backup working. This will avoid
possible conflicts with dependencies from other projects.

To do so, make sure that virtualenv is installed in your computer
by running one of the following:

$ virtualenv
$ python -m venv

One of both above will work. After that, create a virtual environment.
For this example we will call it ```drive-backup```:

$ python -m venv drive-backup

Next step is activate this virtual enviroment, by running the
```activate``` or ```activate.bat``` command. You will see that
this is achieved because the prompt will change:

$ cd drive-backup
drive-backup$ source ./bin/activate
(drive-backup) drive-backup$

Now we are ready to install the google libraries for authentication
and for managing the google api:

(drive-backup) drive-backup$ pip install --upgrade google-api-python-client
(drive-backup) drive-backup$ pip install google-auth-oauthlib

## We are ready for deploy the application

[Grab the latest release](https://github.com/rlunaro/google-drive-backup/releases/)
of the application and uncompress it:

(drive-backup) drive-backup$ unzip google-drive-backup_XXXX.zip

## Config many things

### logging.json

The entry ```filename``` must be configured to indicate where the log files
will be placed:

"filename" : "drive-backup.log",

By default they are left in a file calle ```google-drive.log```, but they
can be left wherever you want. In a linux system, a good place is ```/var/log/drive-backup```.

BTW, you can configure the maximum size of the logging file and the number
of log files to keep.

### config.json

Create a ```config.json``` file by renaming the provided example-config.json:

$ mv example-config.json config.json

And do the necessary configurations:

"emailFrom" : "YOUR GOOGLE EMAIL ACCOUNT HERE",
"emailTo" : ["A LIST OF EMAILS TO NOTIFY, CAN BE LEFT EMPTY"],

**runBefore, runAfter**

These are placeholders to run additional commands that must be run
before the backup is made and after the backup is made. You
can leave them empty if you don't have anything to run:


"//2" : "config of directories / files to backup",
"runBefore" : [],
"runAfter" : [],

Or -let's say- you need to run a script to make a full
backup of your database. In that case, you can place
something like:

"//2" : "config of directories / files to backup",
"runBefore" : [ "/root/full-backup-database.sh" ],
"runAfter" : [ "/root/clean-last-backup.sh" ],

**resourcesToBackup**

The next step is to properly configure the list of folders
or files to make backup:

"resourcesToBackup" : [ "/my_very_important_dir" ],

__windows users__ bear in mind you will have to use backslashes
and double backslash:

"resourcesToBackup" : [ "c:\\my_very_important_dir" ],

**verifyUploadedFiles**

__I recommend set this to "true"__: it will make an MD5 sum of the
remote and local files and check that they match.

**dailyPolicyFolder, monthlyPolicyFolder, yearlyPolicyFolder**

How the folders for daily, monthly and yearly copies be called.
You can leave them as is.

### drive_backup.sh

You have to configure properly the script ```drive_backup.sh```. Edit it, and
perform the following change:

drive_backup_home="PUT-HERE-THE-HOME-OF-YOUR-APPLICATION"

This is the directory where you have created the virtual environment.

**VERY IMPORTANT:** give execution permissions to this script by running:

$ chmod u+x drive_backup.sh

### drive_backup.cmd

The same changes done for the linux script have to be made for the windows users
on this line:

set drive_backup_home=CONFIGURE HERE

## And we are ready to run

Now you can run the application like this:

$ ./drive_backup.sh

**The first time** you run the application, it will request for permission
to access your google drive and gmail showing a screen like this:

![step 0](img/oauth_0.png)

![step 2](img/oauth_1.png)

![step 2](img/oauth_2.png)





19 changes: 19 additions & 0 deletions docs/privacy_en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# PRIVACY POLICY OF THE APPLICATION drive-backup

This application doesn't gather any personal data data.
It is simply a medium to transfer automatically the data
placed in a directory of the user computer to google drive.

Once this step is done, the application will send an email
reporting the sucess or failure of the operation.

In every case, the data will remain with the user and
they are never gathered.

## This application is given with the purpose of it might be useful

This application is send "as is", **without any garanty**.
It is give with the expectancy that it will useful to third
parties.


23 changes: 23 additions & 0 deletions docs/privacy_es.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

# POLÍTICA DE PRIVACIDAD DE LA APLICACIÓN drive-backup

Esta aplicación no recoge datos de caracter personal de ningún
tipo. Simplemente es un medio para transferir automáticamente
los datos situados en un directorio de un ordenador a una
cuenta de google drive titularidad del propio usuario.

Una vez realizado este paso, la aplicación mandará un correo
electrónico informando del éxito o del fracaso de la operación.

En todo caso, los datos permanecerán en todo caso a disponibilidad
del usuario y no se recogen con ninguna finalidad.

## Esta aplicación se entrega gratuitamente con el propósito de que sea útil

Esta aplicación se entrega "como está", **sin garantía de ningún
tipo**. Se ofrece con la esperanza de que sea util a terceras
personas.




26 changes: 26 additions & 0 deletions drive-backup.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
rem
rem drive_backup.cmd
rem

set PYTHONIOENCODING=UTF-8

if "%drive_backup_home%" == "" goto do_init

goto skip_init

:do_init
set drive_backup_home=CONFIGURE HERE
set PYTHONPATH=%drive_backup_home%;%drive_backup_home%\src
set PYTHON_HOME=%drive_backup_home%
set PATH=%PYTHON_HOME%\Scripts\;%PATH%
set PYTHON_EXE=%PYTHON_HOME%\Scripts\python.exe

:skip_init

"%PYTHON_EXE%" -u %drive_backup_home%\main.py ^
--config="config.json" ^
--logging="logging.json" ^
%1 %2 %3 %4 %5



23 changes: 23 additions & 0 deletions drive-backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
#
# drive_backup.sh
#
#

PYTHONIOENCODING=UTF-8

if [ -z "$drive_backup_home" ]
then
drive_backup_home="PUT-HERE-THE-HOME-OF-YOUR-APPLICATION"
PYTHONPATH="$drive_backup_home;$drive_backup_home/src"
PYTHON_HOME="$drive_backup_home"
PATH="$PYTHON_HOME/bin:$PATH"
PYTHON_EXE="$PYTHON_HOME/bin/python"
fi

"$PYTHON_EXE" -u "$drive_backup_home/main.py" \
--config="config.json" \
--logging="logging.json" \
$1 $2 $3 $4 $5


4 changes: 3 additions & 1 deletion example-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
"emailFailure" : "email_failure_template.txt",

"//2" : "config of directories / files to backup",
"runBefore" : ["EXAMPLE-OF-ADDICIONAL-COMMAND-TO-RUN.sh"],
"runAfter" : [],

"resourcesToBackup" : [
"THE LIST OF DIRECTORIES OR FILES TO BACKUP"
"THE LIST OF DIRECTORIES OR FILES TO BACKUP (DON'T end in /)"
],

"verifyUploadedFiles" : "true",
Expand Down
26 changes: 0 additions & 26 deletions google-drive-backup.bat

This file was deleted.

23 changes: 0 additions & 23 deletions google-drive-backup.sh

This file was deleted.

2 changes: 1 addition & 1 deletion logging.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"handler1" : {
"class" : "logging.handlers.RotatingFileHandler",
"encoding" : "utf-8",
"filename" : "google-drive-config.log",
"filename" : "drive-backup.log",
"maxBytes" : 1024000,
"backupCount" : 3,
"formatter" : "formatter1"
Expand Down
7 changes: 7 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
site_name: Drive backup
nav:
- Home: index.md
- Install : install.md
- Privacy policy (english): privacy_en.md
- Privacy policy (spanish): privacy_es.md

Loading

0 comments on commit 9858fae

Please sign in to comment.