项目作者: rahulsh1

项目描述 :
Backup directories in compressed encrypted form
高级语言: Python
项目地址: git://github.com/rahulsh1/encrypted-backups.git
创建时间: 2018-09-23T04:59:43Z
项目社区:https://github.com/rahulsh1/encrypted-backups

开源协议:

下载


encrypted-backups

Backup directories in compressed encrypted form

Supports delta backup of individual directories, zipping up the directories and also optionally encrypting them.
This is supported for *nix platforms only.

Prerequisites

  • Python 3

Install the missing modules using easy_install or pip.

For encryption, you need GPG

OSX

  1. brew install gpg

Linux

  1. apt install gpg

Then install
pip install python-gnupg

Script

  1. ./backup_folders.py -h
  2. usage: backup_folders.py [-h] [-e EXCLUDE] [-l LOGFILE] [-q] [-z]
  3. [-zn ZIPNAME] [-zd] [-u USEREMAIL]
  4. BACKUPDIR DESTINATIONDIR
  5. positional arguments:
  6. BACKUPDIR Specify the source directory to backup.
  7. DESTINATIONDIR Specify the directory where the backup is stored.
  8. optional arguments:
  9. -h, --help show this help message and exit
  10. -e EXCLUDE, --exclude EXCLUDE
  11. Exclude the following directories from backup.
  12. -l LOGFILE, --logfile LOGFILE
  13. Specify the logfile.
  14. -q, --quiet Do not print to stdout.
  15. -z, --zip Create tgz file for the directory
  16. -zn ZIPNAME, --zipname ZIPNAME
  17. Create named tgz file for the directory
  18. -zd, --zipdel Create tgz file for the directory and delete the directory
  19. -u USEREMAIL, --encruseremail USEREMAIL
  20. email-id for encryption purposes

Examples

  1. # Backup 'my_dir_one' to '~/backup/full', logging to backup.log
  2. $ ./backup_folders.py -l backup.log ~/Documents/my_dir_one ~/backup/full/
  3. # Backup 'my_project' to '~/backup/full' skipping any directory with name 'target'
  4. $ ./backup_folders.py -e target -l backup.log ~/Documents/code/github/my_project ~/backup/full/
  5. # Backup 'my_dir_one' to '~/backup/full' in Quiet mode, logging to backup.log
  6. $ ./backup_folders.py -q -l backup.log ~/Documents/my_dir_one ~/backup/full/
  7. # Backup directory and also create a named tgz file called backup1.tgz
  8. $ ./backup_folders.py -q -z -e target -l backup.log -zn backup1 ~/Documents/code/github/my_project ~/backup/full/
  9. # Backup directory and also create a tgz file and delete the directory from backup folder
  10. $ ./backup_folders.py -q -z -zd -e target -l backup.log ~/Documents/code/github/my_project ~/backup/full/

With encryption

You need to run create_keys.py once to generate the gpg public/private keys. This is created under $HOME/.gpghome

  1. # Create one time config with email-id with given password
  2. $ ./create_keys.py user@domain
  3. Password:
  4. # Creating the backup
  5. $ ./backup_folders.py -q -e target -l backup.log -u user@domain ~/Documents/code/github/my_project ~/backup/encrypted/
  6. # Decrypting the file. This will generate my_project.tgz in ~/backup/encrypted directory.
  7. $ ./decrypt_file.py ~/backup/encrypted/my_project.tgz.gpg
  8. Password: *****