pyS3sb is a Python rewrite of s3sb, a basic shell script package to back up files and databases to Amazon S3.
Copy/rename config-sample.py
to config.py
and tune the values as desired. If using a shared hosting environment, please remember to check the permissions for config.py
to ensure it can’t be read by other users if necessary. $ chmod 600 config.py
should do the trick.
Prerequisites: mysqldump
and gzip
; Python 3; and boto3
in your environment. If you have pip installed, run pip install -r REQUIREMENTS
in the pyS3sb directory to automagically install boto3
. See the python2
branch for a legacy version of the tool that uses Python 2.
pyS3sb is designed to work in tandem with cron
. Set up cron jobs to call pys3sb
with the --daily
, --weekly
and --monthly
options, something like this:
0 0 * * * cd /path/to/pys3sb; python s3sb.py --daily
0 0 * * 0 cd /path/to/pys3sb; python s3sb.py --weekly
0 0 1 * * cd /path/to/pys3sb; python s3sb.py --monthly
This will call pyS3sb at the appropriate times and run tasks according to their defined frequency in the config file. Depending on how your environment is set up, you may need to adjust your $PATH or invoke your .bashrc file to ensure cron
runs the right version of Python, e.g:
0 0 * * * source ~/.bashrc; cd /path/to/pys3sb; python s3sb.py --daily
You can also specify that a single task be run using the --only
option, which must be combined with the frequency of the task you wish to run. For example, to run a task named blog-backup
which would normally run daily, you could run:
$ python s3sb.py --daily --only blog-backup
You can also use the --test
option which will check your config file without running any tasks.
pyS3sb is a work in progress, so please stay tuned.