Backing-up the Ubuntu system

Redundancy is multiple copies of a file. In the case of git-annex, dropbox, and other file syncing solutions, the software works to make sure the same files are present everywhere.

Backups are copies of files from a certain point in time. Backups are often either separate systems or external hard drives.

Consider this use case: you’re using git-annex to sync video files between you and a friend. Your friend puts a huge video file in the file share. You add it to your project. Then your friend runs out of diskspace and removes the video file. They software syncs the file deletion across all the clients. Now that file is gone. If you have a backup from the period of time where you had the file, you can recover it, but having redundancy didn’t work since the removal was intentional.

Maybe you also delete a file you think you don’t need, but end up needing it later. If you have a backup from that point in time, you can get the file. If git-annex is auto-syncing files (or you manually sync them as well), then the file is gone, as you removed it.

dd command will do the job.

Get backup of a partition in the form of image:

$ sudo dd if=/dev/sda1 of=/home/jt/part.img

1 Like

In our case we would choose one folder to serve as an archive and we never delete anything. I think you can also configure it in a way that the files would only get deleted locally and not on the server. But I see what you mean, cheers.

I know this thread is a little old now, but I wanted to share the process I use to backup my system, and photos, just in case any one else maybe looking for this.

There really is no reason to use external tools, as some of the best backup tools are all ready included with Linux, and all it take is creating a small script file.

This is my script file, residing in my root scripts folder.

#!/usr/bin/env bash
# Backup system
# Preserve permissions and ACL's
# Run the task on processor nodes 10 and 11

taskset -c 10,11 \
    rsync -aAX --delete \
    --exclude=/dev/* \
    --exclude=/proc/* \
    --exclude=/sys/* \
    --exclude=/tmp/* \
    --exclude=/run/* \
    --exclude=/mnt/* \
    --exclude=/media/* \
    --exclude="swapfile" \
    --exclude="lost+found" \
    --exclude=".cache" \
    --exclude="Downloads" \
    --exclude=".VirtualBoxVMs" \
    --exclude=".ecryptfs" \
    / \
    /mnt/BACKUP_DRIVE/System \

Lets break this down a little, first the rsync backup part of the script:

  • -a
    This option is a combination flag. It stands for “archive” and syncs recursively and preserves symbolic links, special and device files, modification times, group, owner, and permissions.
  • -A, --acls
    Preserve ACLs (implies --perms)
  • -X, --xattrs
    Preserve extended attributes
  • --delete
    Delete extraneous files from destination dirs (be careful with this) if a file in the destination is not in the source it will be deleted. So make sure that your source and destination are correct.
  • --exclude=PATTERN
    Exclude files matching PATTERN (There are a whole bunch of files that you don’t need to backup, this excludes them.
  • /
    The root directory I want to backup.
    The destination drive.
  • &
    Run the process in the background

So that’s the backup part of the script, after the initial backup it only copy across changes in the root system. Now an issue I found was that when I ran this backup my system could slowdown, even hang, as the process was running. I have a 12 core CPU, and the load was shared across all cores, meaning other running processes would suffer.

  • taskset -c 10,11
    What this does is assign processor cores 10 and 11 to the task, allowing my machine to keeps running smoothly while the backup is running. I especially found this useful when I had to transfer 2Tb of images to a new drive.

My backup script can be set as a cron job, or ran manually as I desire.
In case of system failure, i just need to boot with a live USB, and copy the files back using the same process.

I have a separate script to backup my photos directory, it is pretty much the same:

#!/usr/bin/env bash
# Backup photos preserving permissions
# Run the task on processor nodes 8 and 9

taskset -c 8,9 \
    rsync -ap --delete \
    /mnt/USER_DATA/Photos/ \

Nothing wrong with using the basic tools already included in a standard Linux system. But if you’re looking for a specialized tool BorgBackup seems to be quite a popular solution these days:

1 Like

Free software doesn’t need to be backed up. If you lose a hard drive you buy another one and re-install.

On linux systems what I do back up are the /home directory and /var/www/html (where I do web development). I like to copy my /etc/fstab and /var/spool/cron directories too but they never change, so one copy is enough.

I have two internal hard drives (three actually). OS on an SSD, /home on a six terabyte WD red drive and another 8 terabyte WD that mirrors the first.

Heres’ my crontab

 # m h  dom mon dow   command
0 0 * * * /usr/bin/updatedb 
0 1 * * * /usr/bin/rsync -avz --exclude 'cache' /var/www/html/ /disk1/www/html
0 2 * * * /usr/bin/rsync -avz --exclude 'cache' /home/ /disk1

…where disk1 is my backup mirror disk
That rsync takes a long time to run the first time but quickly thereafter.

1 Like

Regarding BorgBackup:

I recently packaged Vorta,a BorgBackup-GUI, as Flatpak.
It is already available on Flathub.

1 Like