Linux – How to backup a running system

backupddlinux

I have a running Linux system, and I'd like to have a full backup of it using dd, which, in my limited knowledge is the only tool every system has.

The distro doesn't matter mainly because I should apply this approach to several different servers with different flavours installed, and I cannot install new software on these servers.

What is the most generic and efficient way to complete such task?

Best Answer

Not so much a solution as a few nuggets of advice which may be helpful to consider if using tar/cpio/rsync etc. First, it might be a good idea to backup from a bind mount of your source filesystem (mount --bind source mntdir). This will have a similar effect as the --one-file-system options to rsync and tar and -xdev with find. It has the advantages of working if these options are unavailable (perhaps due to an old version, although note that bind mounts were introduced in Linux 2.4) and allowing files underneath mount points to be backed up, which may be desirable in some cases.

Second, I would advise to use numeric uids and gids where possible (--numeric-owner for tar, --numeric-ids for rsync and --numeric-uid-gid for cpio). If you restore a backup without this and an owner/group no longer exists or the uid/gid is different (this may happen particularly if a live disc is used to restore the backup), you can have one set of uids/gids used when restoring which become invalid after /etc/passwd and /etc/group are restored.

Also, take a look at clonezilla. The methods that they use to do the bulk of the backup may not be of use to you, but when it runs has options to backup boot sectors/partition tables and supports both MBR and GPT, so there may be some scripts there which can be copied/adapted to your purposes.

As a final 2 cents, I would consider rsync to be the standard way to do this. It is surely the most efficient method when doing incremental backups, although not so much for a one off full backup. Sure, it is not ubiquitous, but I think it is a mistake not to include it in the server edition of a distro. It may well already be installed on all of your servers.

Related Question