Schlagwort-Archiv: backup

Encrypted Dropbox Backups

Data backups are probably one of the most annoying topics in the world of computers. Yet they are a necessity if you want to minimize your risk of data loss. There is tons of commercial products that do the job and probably more strategies employed than people living on earth.
So I just want to describe my approach and if someone comes across this I am happy to hear about your opinion in the comments!

I generally divide of all the files on my computer in three tiers:

  • Completely reproducible: Everything that is reproducible with low or no effort. For example all the stuff that comes with a Linux distro, binaries, etc.
    This tier obviously needs no backup.
  • Large non-reproducible files: Music, Pictures, Movies, etc. Everything that I want to keep but it’s too large to just keep it in a Dropbox folder or something comparable.
  • Small non-reproducible files: Mostly documents like invoices, CVs, config files. These files are small and thus easier to handle in terms of backup.

So with two different tiers of files that need backups I also have two different strategies that I use:

External hard drive Backups

I have a little one liner shell script that just calls rsync with a couple of parameters and creates a copy of all the files in my home folder. The files in the exclude list file are skipped, for example the „Downloads“ folder where I generally have large stuff that I don’t really need lying around. Have a look at the script here.

There are two Problems with this approach:
First: It’s not technically a backup, it’s just a copy. A „real“ backup has to be incremental, such that I could go back to any snapshot I ever took. With a copy if you ever damage an original file and run a backup that file is lost. But I decided that it is good enough for me.
Second: It’s not off site. It does not protect my data from a fire or a very thorough thieve who steals both my computer and the external hard drive.

Encrypted Dropbox Backups

Dropbox is a service that I guess many people use for file backup and it’s great and easy to use, but unfortunately in the post-Snowden era we have to assume that everything that is on Dropbox is readable for at least the US-Government agencies. If you properly encrypt your data before you send it to Dropbox however you’re good to go.
That is if we assume that the employed encryption algorithm is unbroken. If you followed the Snowden revelations you might feel uneasy to trust any kind of encryption, but just as Bruce Schneier says: I trust the mathematics.

So I wrote a little script that collects all those smaller files I want to backup, packs them into a tar-gzip archive with a time stamp in the filename, passes this to gpg, which uses the CAST5 Algorithm to encrypt the tar file using a user supplied password.
Finally, the encrypted file is moved to the Dropbox directory and thus automatically uploaded to Dropbox. Have a look at the script here.

I don’t have s strict rule when I execute those script, I just do it sometimes when I think of it, which obviously is not optimal and I will try to find a doable way of doing it more regularly.

So that’s it, please let me know what you think about this in the comments or describe your approach.

File backup with rsync

Most people would agree, that backing up your files regularly is very important. However: Most people don’t. I don’t have any scientific data to support this, but it is my personal experience.

© Peter Steinfeld

When I switched from Windows to Linux (a long time ago) I was used to nice GUI based backup tools like Cobian backup, which just sits there in the background and takes care of everything. I wanted something similar for linux. So I tried mostly GUI stuff like Unison, but I never got it to work quite properly. If you are looking for a GUI backup solution, I can’t help you… please stop reading and close your browser… maybe take a walk? (Or look here)

There are many different ways to back up your system or files. You can choose to mirror your whole hard drive including all partitions and boot information and what not. You can back up your operating system, so you can go „back in time“ if you misconfigure something in the future. Or you can just backup your personal files: Pictures, Videos, Music, Documents. For me the latter is sufficient since after a complete hardware crash I would setup a fresh system anyway.

I finally found a suitable program in rsync which is the go to guy of file synchronization in *nix systems. Many other tools even rely on it, e.g. Unison. Rsync is very feature rich, has support for SSH and can run as a daemon. (However none of this is important for a backup solution).

So here is what I do: Every once in a while I think it’s a good day for a backup, plug in my external hard drive and run a shell script that calls rsync with a couple of parameters. (A more organized person would probably have some sort of schedule. Not me. Please don’t judge!) Here is what it looks like:

rsync -avP --exclude-from='/home/niklas/rsync_excludelist' --delete-excluded --delete --stats /home/niklas/ /media/Backup/niklas

what does it all mean?

  • -a (archive) tells rsynch to leave file properties intact (i.e. owner, access rights, etc) This only works if you are not backing up to a different file system!
  • -v lets rsync be verbose and -P gives you a progress bar
  • –exclude-from specifies the exclude file, I will talk about that later
  • –delete makes sure files you delete in your original data will also be deleted from the backup
  • –delete-excluded means that files or directories you choose to exclude later will then be deleted from the backup
  • –stats lets rsync summarize the whole operation after it is done
  • then you must give the source and destination directories (for me that is my home folder and a folder on my external drive called „Backup“

I chose to exclude several directories, my exclude file looks like this:


The reason for excluding Dropbox is obvious: It would be super dumb and redundant. I do not backup my Downloads folder, because there it’s often quite big, full of crap and if I want to keep something I move it to another folder. .gvfs (for GNOME virtual file system) is where remote file systems are mounted. I frequently mount my home folder at the university and don’t want it included in the backup (I am not sure if it even works that way).