Package: backup-to-dropbox
Backup To DropboxThis is a small utility written in python3 that allows generating tar-gzipped backups and upload them to aDropboxaccount.InstallingUsing pip:$ pip install backup-to-dropboxOr manually running within the project's root folder:$ python3 setup.py installDependenciesThe only requirements for this tool are:python3(>= 3.6) anddropbox(>= 10). Optionally, if you want to encrypt the backups using GPG thepretty-bad-protocolis needed too.UsageObtaining an API KeyIn order to use this tool a Dropbox API token is needed. To obtain one, an app needs to be created and an OAuth2 token generated for it.
All this can be done with a few clicks thorough Dropbox's web interface.In this linkyou can find a step-by-step guide.IMPORTANT NOTE:Istrongly suggestthat you only give permissions to the app to access a single folder. This minimizes the risk of exposing the whole account in case the token gets stolen but also means that all the backups are going to be neatly stored and tucked away in a separate folder.Generating a backupIn order to generate a backup the application takes two required arguments: the backup's name and the list of paths to back up.The name is used to create a subfolder under the Dropbox's root (or the application's folder root) where all the backups with the same name are going to be stored.A tar-gzipped file is going to be created with each one of the paths that are given which actually exist.
Both, full and relative paths can be used and they will be added to the tar-gzipped as given.The file is going to be uploaded with the nameyyyy-mm-dd-HHMM.tar.gzat the time of the execution if the file already exists, the backup will fail.Keeping a max number of backupsOne of the features included is the ability to only keep a certain number of backups. This is done by passing the flag--max-backupsto the program followed by the number of backups to keep.The application will delete the oldest files in the given backup name folder until the count is the argument passed minus one.
This is done so as to leave space for the backup being currently generated.Encrypting the backupCurrently, it is supported to encrypt the generated backup using GPG targeting a particular key.
In order to use this, the public key needs to be already located in agpgcompatible keyring in the host.The following arguments are used to enable the encryption:--gpg-encrypt <KEY_FINGERPRINT>: This enables the encryption and sets the key to use for encryption.--gpg-home <GNUPG_HOME>(optional, default: platform dependent): If set, it uses the path given as the gnupg home folder.--gpg-pubkeyring <PUBKEYRING_FILE>(optional, default:pubring.gpg): If set, it uses the file given as the public key-ring.When encrypting the backup the filename generated will have the.encextension.To decipher the backup, in a host where the secret key is located run:$ cat 2020-05-01-2300.tar.gz.enc | gpg --decrypt > 2020-05-01-2300.tar.gzExample$ ./backup-to-dropbox.py --api-key <api-key> --backup-name myserver1-logs --max-backups 10 /var/log/Generates a backup of the/var/logfolder and uploads it under[Apps/theappyouregistered]/myserver1-logs/yyyy-mm-dd-HHMM.tar.gz.
Only the last 10 backups are kept.DetailsIf the backup is not larger than 150MB, a single request is used to upload the file.
In case the file to upload is larger, a multi-request session where each request will upload a 150MB chunk.
Uploading a file larger than 350GB is not possible, this is a Dropbox limitation.LicenseMIT