Files and db backup script powered by Duplicity and PyInvoke
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


alt tag

Backup Jeans is a backup script that has one goal: to make process of backing up site's database and files simple and hassleless no matter what stack / language / cms your web app is running on.

The script itself is a PyInvoke script that uses Duplicity to do scheduled backups.


1. Dependencies

Backup jeans needs PyInvoke, Duplicity and Boto to be installed on your system.

1.1 Approach 1

If you're on a relatively fresh Debian installation, you can do: sudo apt-get install python-invoke duplicity python-boto

1.2 Approach 2 (Recommended)

To make sure you have latest versions of dependencies it's better to install them trough Python's package manager called PIP:

1.2.1 Installing PIP (if you don't have it installed)

sudo apt-get install python-pip

1.2.2 Installing dependencies via PIP

pip install invoke duplicity boto, depending on your system, you may need to run this command as sudo pip install invoke duplicity boto.

2. Install script itself

You can put anywhere you wish, but I reccommend to create a backup directory in your project and put it here, so it will leave there. You can git clone to this directory or just wget` and you're almost ready to go.


Edit downloaded, find section 1 configuration and enter your data in lines marked as #CHANGEME.


You can see all commands available by running invoke --list command. To get individual per command help, use invoke --help <command_name>, for example invoke --help backup_files to get a help for backup_files function.

Main functions of the script are: invoke backup_files and invoke backup_db, these do run backups of your files and database respectivelly.

You can test if your backup configuration is correct by running invoke backup_files_verify or invoke backup_db_verify. Backup jeans will do a --dry-run and will output results on the screen.

Now you can setup a cronjob to execute these commands on a schedule.

1. Automatic cronjob setup

Backup jeans can automatically setup a cronjob for you. To do so run invoke cron_setup and follow on screen instructions.

2. Restoring backups

To restore your project files run invoke restore_files --dest=/path/where/to/restore and backup jeans will restore your latest backup into /path/where/to/restore directory. If you want to restore a file from a given timeframe, you can use a time option. For example, let's restore files that we've backed up 3 days ago: invoke restore_files --dest=/path/where/to/restore --time=3D. For more available options, please refer to command help invoke --help restore_files


While this script totally works for me, it may contain bugs, so be careful and check if your cronjobs are executed properly. Also as a good practice, don't forget to test your backups on a regular basis.