Package: duplicity-backup-s3
Duplicity Backup to S3Duplicity backup to S3 for production servers using simple yaml file.LicenseFree software: Apache Software License 2.0FeaturesThis is a duplicity command line backup wrapper that will backup to S3 that is using a validated yaml configuration file using modern and awesome CLI patterns. The commandsincremental,list files,status,verify,cleanup,removeandinitare implemented.The primary use case to build this (yet another one) CLI wrapper for duplicity, is to be able to deploy the command in production and inject it into acron.dailyand having a hands-off automated backup of production servers. We use it a KE-works to automate our production server backups to Amazon S3.OS Dependenciesduplicitypython-bototo connect to S3InstallationYou can either install this as a system command on any operating system supporting Python 3.5 or later.To install as global command from PyPI:sudopython3-mpipinstallduplicity-backup-s3To install for your user only from PyPI enter the following commmand:python3-mpipinstall--userduplicity-backup-s3To install from the git repository (latest master branch):python3-mpipinstall--usergit+https://github.com/jberends/duplicity_backup.git#wheel=duplicity_backup_s3First useTo first use, you need to create a configuration yaml file. You can use the helper commandinitfor that. Use the built-in help function for your enjoyment.# help is neighduplicity_backup_s3--help# and to init the configuration YAML fileduplicity_backup_s3initIt will drop you aduplicity_backup_s3.yamlin your current directory. That may look like this:aws:AWS_ACCESS_KEY_ID:foobar_aws_key_id# your amazon S3 user that has write right to a backup bucketAWS_SECRET_ACCESS_KEY:foobar_aws_access_key# your amazon S3 user secretbackuproot:/home# the backup 'root' path. Everything underneath is considered for backup.excludes:-"**"# a list of exclude paths. May be '**' to exclude everything except what you includeincludes:-/home/Pictures# a list of includes, which are full paths-/home/Musicremote:bucket:'<an_s3_bucket>'# S3 bucket namepath:'__test'# subpath within the bucketfull_if_older_than:7D# default is incremental, will create full backup every 7Days.You can alter the configuration file to your liking. The command will check the configuration for its validity and tell you what went wrong and what you need to correct. If you made mistakes, it can be beneficial to checkout the duplicity man page for more information on that topic. However we tried to be as verbose as possible to guide you in the right direction.First backupTo perform your first backup, which is a full one, use the following command:duplicity_backup_s3incr--verbose# or if the config is somewhere elseduplicity_backup_s3incr--config/path/to/configuation.yamlThat might take time according to the size of the backup.
You can see the volumes being uploaded to your configuredS3 bucketusing the S3 console.To check the backup collection, list and verify the contents of the backup you may use:# collection statusduplicity_backup_s3status# list all filesduplicity_backup_s3list# verify backupduplicity_backup_s3verifyRemove old backupsTo remove older backups, duplicity provides some commands. We implemented those in theremovecommand.# to remove backups older than 7Dduplicity_backup_s3remove--older-than7D# to remove older backup except the last 4 full backupsduplicity_backup_s3remove--all-but-n-full4Restore backupsTo restore backup we implemented therestorecommand.# to restore backups from yesterday to a current directoryduplicity_backup_s3restore--time1D# to restore specific subdirectory from a specific date/time to a custom directoryduplicity_backup_s3restore--dirspecific_subdir\--time2020-12-08T22:22:00+01:00--target~/a_restoredirUsing this as daily backup in a cronjobTo use this in a daily cron job, you can alter thecrontabfor the userrootcrontab-uroot-eYou can alter the crontab in the following way# Daily backup and remove older backup
7 4 * * * /bin/duplicity_backup_s3 incr --config=/path/to/conf.yaml && /bin/duplicity_backup_s3 remove --older-than 7D --config=/path/to/conf.yaml
# | | | | +- the command to execute
# | | | +--- day of the week (0-6) Sunday=0 (*=every day)
# | | +----- month of the year (*=every month)
# | +------- day of the month (*=every day)
# +--------- hour of the day
#----------- minute in the hourCustom EndpointsYou can configure custom endpoint and custom additional arguments in the configuration yaml file. The custom endpoint can be configured in the sectionremote > uriand the additional arguments that are directly passed to duplicity can be configurated in theextra_argssection as a list in the yaml file....remote:uri:"s3://ams3.digitaloceanspaces.com/bucketname/subpath"extra_args:---some---additional---arguments---here=3TODOimplement appdirs for default configuration file placementimplement restore for restoringAllow for custom s3 storage endpoints. Included in v1.2.0 with thanks to @denismatveevIf requested migrate--s3-european-bucketsto configuration fileIf requested implement GPG/Encryption capabilities. Possibly reusing code ofkecpkg-toolsto manage certificates. Included in v1.2.0 with thanks at @denismatveevCreditsThis package was inspired by the great work done by the duplicity team, back in the days.This package was inspired by the great amount of bash code by theduplicity_backup.shproject.This package is thankful on my knees to the great work done by the Authors and contributors behind theClickproject, packing tons of CLI awesomeness since 2014.This package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.
\n\n# Changelogv1.2.1 (31JAN23):+1: Reinstating python 3.6 compatibility to ensure make it compativle with older Centos 7/RHEL installations that ship python 3.6.v1.2.0 (23JAN23)This release is named "The Other S3 As Well"-Release. We now support other S3 storage providers, other than only the Amazon one. So now you can use digitalocean (tested) or even dropbox for that matter as a remote storage for your backups.:star: Added the optionextra_argsin the configuration yaml. Theseextra_argsmay be provided as a list in the yaml and they are passed down to duplicity. See the duplicity documentation for the exact use of them. (#8):star: Added the option to provide the full remote uri in the yaml sectionremote > uri. This will circumvent the construction of the uri based on endpoint, bucket and path and ensures that when you know what you are doing a lot of different storage providers may be used. See the duplicity help documentation how to provide the remote uri correctly. (#8):star: Added GPG encryption possibilities. Thanks to @denismatveev. (#5):star: Added the ability to use custom S3 endpoints. Now it does not default to amazon S3 and you can use S3 compatible storage targets such as digitalocean (tested on Digital Ocean). Thanks to @denismatveev. (#5):+1: Improvedinitcommand to add a flag--quietfor less chatty way of initialisation of the config file. (#8):+1: Thorough spring cleanup. Dropped support for Python releases below 3.7.Black-ened,pyupgrade-ed,isort-ed the codebase. Fixed tests and added tests for newer python releases. Switched to dependabot for dependency management.  (#8)v1.1.0 (8DEC20)added restore command implementation.v1.0.2 (3APR20)Added appdirs to the setup.py requirements.v1.0.1 (UNRELEASED)Not released to the public.v1.0.0 (16DEC19)First production release.implemented appdirs, such that the configuration file can be safely placed and located from a known configuration directory on disk.addedremovecommand to remove collections from the backup target after a specified time. Please consult theduplicity_backup_s3 remove --helpdocumentation for guidance.addedinitcommand to initialise the configuration in an interactive fashion for users.various development improvements, e.g. GitHub actions for testing and publishing to PyPI; removed all flake8 warnings and pydocstyle errors. Added pre-commit hooks. Code is A++ grade now.v0.5.0 (5JUN19)First initial public release.commandsincr,list,status,verify,cleanupimplemented.added yaml schema check for the configuration file.v0.2.0 (3JUN19)Internal release.migrated to command structure. Now offersincrandinitv0.1.0 (3JUN19)Internal release.First release on PyPI.