How to backup debian system?

10,329

Solution 1

If you need to backup just the system configuration (which at the end of the day usually is about third of the content of a system), all you should need is a list of packages installed + their configuration. The list of installed packages you can get with your packaging utility, the system-wide configuration lives in /etc (in /usr/local/etc and /opt/<vendor>/etc if you have some really non-standard stuff installed) and you might also want to throw in /root. Hence you can just backup the configuration directories and the list of installed packages and you should have everything needed (for the first third).

The other two thirds would be:

  • private user data (home directories), and

  • public user data: data accessed by various services running on the system - usually mail queues, data served by http daemon. In some sense virtual machines or change-roots could fall into this category as well.

Regarding the system-wide back-up, apart from options mentioned in the other answers, if your installation (be it a virtualised guest or the VPS host) lives on a separate filesystem, you can either use the filesystem's native backup/snapshot capability (e.g. XFS has this feature) or mount it read-only and dump its containing device (which might be dangerous though). Plain ssh would be more enough to do this.

As with any other low-level system operation, running any the operation in terminal multiplexer, which protects the backup process from possible connection drops, and having a spare ssh connection (preferably served by a different process) is recommendable.

Solution 2

I'm using rsync for file backup. In the /etc/cron.daily put a script like:

EXCLUDES=/etc/rsync/excludes.txt
TARGETDIR=root@::backup-target
BACKUPDIR=/`date +%Y%m%d-%H%M%S`
export RSYNC_PASSWORD="veryverysecret"

rsync --force --ignore-errors --delete-excluded --exclude-from=${EXCLUDES} --delete --backup --backup-dir=${BACKUPDIR} -a -H -X -A / ${TARGETDIR}/current

Of course you have to configure the host-where-to-store-backup. Have a look in the rsyncd.conf man page.

Solution 3

I personally use Dirvish.org It is a disk based file backup that uses rsync over ssh and it is in Ubuntu repositories (so quite likely in Debian's too).

It is easy to configure, does incremental backups to disk, uses encryption to communicate accross the network, expiring old images is simple, only copies changed files, ...

Share:
10,329

Related videos on Youtube

Anthony
Author by

Anthony

Updated on September 18, 2022

Comments

  • Anthony
    Anthony over 1 year

    I have VPS hosting with debian operating system.

    I would like to backup whole system time by time.

    Here is a lot of questions how to backup OS on local machine, but it's not what I need. I have just ssh and superuser account.

    • Admin
      Admin over 11 years
      File backup or image backup? With a file backup you cannot do a full restore without an already working operating system, but ideal for restoring one or more lost/corrupted files; With an image backup, each backup set is huge, but comes with the advantage that a complete system can be recovered to the state it was in at the time of the backup. Restoring a single file from an image is nearly impossible.
    • Admin
      Admin over 11 years
      What retention time? Do you want off site storage? Tapes? Disks?
    • Admin
      Admin over 11 years
      Sorry, I mean image backup. I installed OS, different application and I can do smth to brake it accidentally. For these cases I would like to save all settings. And I think to save image backup - it's a good way.
    • Admin
      Admin over 11 years
      Creating images is very slow as you generally copy the entire harddisk, regardless of what's on it. Usually the system has to go down and booted from a different medium. Perhaps easiest for you is to create an image once in a while and combine that with regular file backups. Best of both worlds.
    • Admin
      Admin over 11 years
      It doesn't matter whether the machine is local or not.
  • Anthony
    Anthony over 11 years
    Thx! Will try it
  • jippie
    jippie over 11 years
    In contrast to your comment above, dirvish is file backup, it doesn't do full disk images. Dirvish is very good to do daily backup of all changed files. It is really fast and economic though for that.
  • frhd
    frhd almost 9 years
    EXCLUDES is a newline separated list of directories/files?