1

(This was originally asked on SuperUser --- they pointed me here as being more appropriate.)

I have a shiny new Debian server running in an Amazon EC2 instance. I've spent a while setting it up and it now works nicely. However, because it's a cloud server, if I (or someone else) presses the wrong button then its virtual hard disk will go pop and I have to do it all over again. So, I want to make backups.

But I'm paying by the byte for storage, so I want to make a small backup.

It should be possible to backup a complete Debian server by recording the set of currently installed packages (which I can do via dpkg --get-selections), the state of the debconf database (which I can do via debconf-get-selections), and then only backing up files that cannot be trivially replaced from the packages --- i.e., everything else. Then restoring the backup should be a matter of reinstalling the packages and dropping the files on top.

The tricky part is determining which files belong to a package and which files don't. Having a static list of subdirectories to backup isn't really good enough due to cruft creep. I need a way to automatically determine whether a particular file needs backing up or not.

This is precisely the sort of thing I don't want to do myself because I'll get it wrong. Are there any tools to allow me to do this?

(Note: I'm not looking for an incremental backup solution. I want to take a complete snapshot.)

  • All installed files from packages cat /var/lib/dpkg/info/*.list, files flagged as configuration cat /var/lib/dpkg/info/*.conffiles. So your list of files to exclude would be the (all_files - package_files + conffiles). Storage just isn't that expensive though. You are probably talking 1-2 gigs, which is what a few cents a month? – Zoredache Oct 24 '13 at 17:35
  • That's not the complete story, though --- for example, /var/lib/dpkg/info/foo.list doesn't contain /var/lib/dpkg/info/foo.list. This is why I don't want to do this myself! – David Given Oct 24 '13 at 17:40
2

Rsnapshot sounds like it would work for you. It does snapshots and incremental backups. It's pretty light on space. Someone over at ServerFault may have a better answer.

| improve this answer | |
  • Actually, I'm already using rsnapshot to back up the valuable data on the server (/home/whatever). But I want a way to backup the entire server filesystem, as efficiently as possible, such that I can recreate the server on another machine if necessary. – David Given Oct 24 '13 at 14:07
  • ...also, I didn't know ServerFault existed. I'll look into migrating the question. Ta. – David Given Oct 24 '13 at 14:08
1

I have the impression the question asked by David Given is different from the one to which Kelbizzle is providing an answer.

I think the question is (correct me if I am wrong): should I lose my current configuration, what is the minimum amount of information I need to recreate it? This means that there is no need to back up files in /bin, /usr/bin, /sbin, /usr/sbin, and so on, because these are the essential components, which are already described by the list of packages installed, which can be obtained with

sudo dpkg --get-selections

So what is left, basically, are the configuration files. A look at Wikipedia's page on the Linux file system hierarchy shows that all essential configurations are contained in the directories

/etc, /opt, /usr/local, /usr/sbin, /usr/share

If you have installed more packages in your home directory you should take care of those; the directory of installation has been chosen by you, so you should know what to back up. lastly, there are the million files which modern Linux hides in your home directory. Thus you will also need to back up

/home/your_name/.[a-Z]* 

Remember, this is a tree of varying depth, there are many sub-directories within sub-directories in it.

Altogether, this is much less than backing up the whole system. This amount of info could be distilled even further, but this order of magnitude decrease (i.e., approximately by a factor 10) should make it affordable, or so at least I hope.

| improve this answer | |
-1

you should use apt-clone instead of dpkg --get-selections and you might have to backup files from /var too.

It always depends.

| improve this answer | |
  • without more details this is just an opinion. Please connect the gaps by giving reasoning in your answer. – asdmin Jul 26 '19 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.