Create system snapshots with CYA
System Saver
The CYA script helps you back up system files, which you can then restore quickly in case of an emergency.
It is always surprising how many users skip regular backups. This negligence can hit you hard when least expected. Backup software generally backs up directories, partitions, or an entire installation.
Some backup tools are used to back up and restore the operating system itself, not the user data. CYA, for instance, is an 80KB Bash script based on rsync that lets the user keep a copy of the system close at hand. CYA stands for "Cover Your Ass(ets)" – I think we all get the gist. CYA does not try to overload you with a graphical interface; instead, it lets you start the backup with a single command – or even automatically.
Versatile
According to the developer, the CYA script, which was developed by Cyberweb Solutions, can create snapshots of any Linux or BSD distribution – and theoretically, even of any system that offers Bash and rsync. CYA understands how to handle most Linux filesystems, including ZFS and Btrfs. The software is licensed under a BSD license, so anyone can view and modify the code for their own use. You can run CYA automatically with systemd or cron or integrate it into scripts.
The way CYA works is similar to restore points in Microsoft's System Restore, which also only backs up the operating system itself without user data. You can reset the system to an earlier status using a restore point. CYA offers the same features. The home directory remains untouched – at least so far. In the latest version, the software saves the user's data separately with the cya mydata
function.
By default, the program automatically or manually creates three snapshots; then, it overwrites the oldest one. You can also tell CYA to create snapshots that it does not overwrite or that do not even appear in the list of backups.
The software backs up without compression or a proprietary format by default, which means that you can easily restore not only the entire installation, but also individual files or directories if required. You do not actually need the cya restore
function; in principle, a file manager or a tool for the terminal is sufficient.
What Installation?
Because the software is a script, you don't need to install CYA in the classic way. Just download it as a ZIP archive [1], which you then unpack, then copy the cya
file to the bin
directory under your home directory or the usr/local/bin
directory. If you want to put the cya
script somewhere else, add the path to the $PATH
variable. Be sure to set the file permissions to make the file executable.
The script is now ready for use. The only other requirement is that the system is configured to use sudo
[2]. Once you have done this, make sure you are in the home directory and execute the cya
command (Figure 1). If nothing happens, log out and back on again – but this should not be necessary for most distributions.
As you can see, the program creates a new user named cya, as well as some directories and files. Snapshots will end up in points/
in the future. The cya.conf
file is still empty – you can store your own configuration options here. The LAST_RUN
file tells you when the software last ran.
The cya help
call reveals all the options and parameters you can use to control CYA (see Table 1). The default settings are fine for many use cases; however, you might want to familiarize yourself with the available options to have the right commands at hand when in doubt.
Table 1
CYA Commands
Command | Results |
---|---|
Create Snapshots |
|
|
Create snapshot (rotating) |
|
Create manual snapshot (no rotation) |
|
Back up your home directory |
|
Manually archive snapshot |
Recovery |
|
|
Restore data |
Other |
|
|
Help for manual configuration |
|
List directories to be backed up |
|
List snapshots you have created |
|
Remove manual snapshots |
|
Linux mount script |
|
Use cases for script integration |
|
Update check |
Configuration
Type cya configfile
to configure. Examples of modifying the configuration are shown here. If you need a rotation setup with more than three slots, you can change MAX_SAVES=""
and write this statement and all the others to the empty cya.conf
file in /home/cya/
. You can then add or exclude files and directories until the result is what you want. The sequence is irrelevant.
Once you have completed the configuration, start the first backup. Simply enter cya save
in the terminal (Figure 2). The script then saves the system except for /home/
. CYA stores the snapshot in the home
directory of the cya user created by the system under the points/
directory.
If the home directory is on a separate partition and you use the automatic method, you must make sure there is enough free space for at least four backups. This number results from the fact that the program keeps three snapshots each for the automatic method and then rotates.
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
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.
-
DebConf24 to be Held in South Korea
Busan will be the location of the latest DebConf running July 28 through August 4
-
Fedora Unleashes Atomic Desktops
Fedora has combined its solid distribution with rpm-ostree system to make it possible to deliver a new family of Fedora spins, called Fedora Atomic Desktops.
-
Bootloader Vulnerability Affects Nearly All Linux Distributions
The developers of shim have released a version to fix numerous security flaws, including one that could enable remote control execution of malicious code under certain circumstances.