🍻


Misc / Backup To Google Drive With Duplicity

“There two kinds of people—those who have lost data, and those who will lose data.”

Hard drives fail, it’s a fact of life. If you use one long enough it will fail, and often without warning. In today’s world of readily available cheap (and often free) cloud storage you have no excuse not to back up your data.

Duplicity is an awesome little tool for Linux (and other POSIX-like operating systems) that makes backing up a breeze. You give it the directory you want to backup, where you want to store the backup, and it will do the rest. It figures out what has changed since the last backup (so as to only upload what’s needed), keeps everything encrypted, and takes care of uploading. When it comes to restoring from the backup you can do a full restore or select specific files (from specific points of time as all versions are saved).

If you have a Google account you have 5GB of storage space you may not even be using, that’s likely plenty to backup your important data, but if not you can always get more.

To get started you will need to install duplicity and the Google Data APIs Python Client Library (assuming you want to backup to Google Drive), both are likely to be found in your distribution’s package manager. On ArchLinux pacman -S duplicity python2-gdata will install the necessities.

Once installed you’re ready to go. The following command will backup all files in /home/foo/ while excluding anything in /home/foo/Downloads/ and upload them to the Google Drive account YOURGOOGLEACCOUNT.

duplicity -v8 --exclude /home/foo/Downloads /home/foo gdocs://YOURGOOGLEACCOUNT@gmail.com/backup

You will have to provide a passphrase for encryption (don’t forget it or you won’t be able to recover your backup!) and your Google account password. It’s as simple as that. On first run it may take a while to finish, but on subsequent runs it will only upload changes that have happened since the last backup.

Last updated on .