Automatic backups to external media
All Systems Go
After these preparations, restart the system. The installation has installed a new rule for the udev daemon; the restart ensures that this rule is automatically applied. If you now plug the backup stick into a free USB port, the backup should start automatically. When the stick's LED stops flashing, the backup is finished, and the stick is unmounted. If you leave it plugged in and mount it again manually, you will see the first backup in the directory day.0
in the file manager (Figure 4).
The script creates additional backups on each subsequent day. On the second day, the content moves from day.0
to day.1
and day.0
contains the most recent backup. This continues for a full seven days – even if you skip individual days. Then the script creates a weekly backup: day.6
becomes week.0
. This takes place just once a calendar week; after four weeks, the scheme continues with monthly backups.
When using rsnapshot for a server that runs every day, entries in the crontab ensure an orderly workflow – such as a weekly backup every Sunday evening and a monthly backup on the first of every month. With desktops and laptops that are not consistently used every day, this is unlikely to work. For this reason, it makes sense to start the backup precisely when the backup medium is plugged into the computer.
If you are wondering why backups are so fast from the second day onward and why the disk space used by the backups only increases very slowly even though the files are stored in so many daily and weekly directories: This is the "magic" behind rsync. The tool copies only the changed files. For files that do not change, rsync only creates a link, or more specifically a hard link. Then what looks like a file day.1/home/bablokb/old-text.odt
is in reality only a pointer to the location of the file day.0/home/bablokb/old-text.odt
and day.1/home/bablokb/old-text.odt
on the stick.
The procedure offers a number of advantages. Instead of copying large files via USB, rsync just creates the entry – it's fast and saves a large amount of space. Nevertheless, each daily backup shows you exactly the status of the directories on the backup date. If you want to see what has changed between today and the day before yesterday, just compare day.0/[...]/<file>.txt
with day.2/[...]/<file>.txt
.
Conclusions
With a little preparation, regular backups are performed automatically. This procedure is particularly recommended for people who are already in the habit of copying their data to an external medium from time to time. As always in the open source world, you can adapt the process to your specific needs.
For example, you could replace the trigger for the backup (inserting the stick) with something else – for a laptop, for example, logging into your home WLAN. The backup should then also logically be created on a network drive.
No matter which method you choose, it is crucial that you make regular backups. Don't forget to check from time to time that the backups do what they promise. In my personal experience, there have been cases where the data were backed up daily to the same magnetic tapes for years. Unfortunately, the tapes were only designed for a low, three-digit number of write cycles, which would have made successful data recovery impossible in an emergency. With modern flash media this scenario is not a worry – but, as the saying goes: It's better to be safe than sorry.
Infos
- GParted: https://gparted.org
- rsnapshot: http://www.rsnapshot.org
- autobackup: https://github.com/bablokb/autobackup-service
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
So Long Neofetch and Thanks for the Info
Today is a day that every Linux user who enjoys bragging about their system(s) will mourn, as Neofetch has come to an end.
-
Ubuntu 24.04 Comes with a “Flaw"
If you're thinking you might want to upgrade from your current Ubuntu release to the latest, there's something you might want to consider before doing so.
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.