Backing up your files is like brushing your teeth. If you skip it too often, you might regret it later. When I first started using Linux, I didn’t think much about backups. Then one day I accidentally deleted a project I had worked on for two weeks. Oops. That’s when I learned about rsnapshot—a tool that can help automate backups and save your digital life.
In this guide, I’ll show you how to set up automatic backups using rsnapshot. Don’t worry if this sounds new. I’ll explain everything in a simple way, just like how I learned it. You’ll walk away with a working backup system and maybe a chuckle or two.
What Is rsnapshot?
Let’s start with the basics.
rsnapshot is a free and open-source tool for making backups. It uses another tool called rsync under the hood.
Here’s what it does:
- Makes copies (snapshots) of your files and folders
- Only saves changes since the last backup (to save space)
- Runs on a schedule, so you can “set it and forget it”
If you’re thinking “snapshot” sounds like a camera, you’re right. It’s like taking a picture of your files. And just like a photo album, rsnapshot lets you go back and see what things looked like before.
It’s perfect for personal computers, servers, or even your grandma’s old Linux laptop (if she’s into that).
Why Use rsnapshot?
When I first tried rsnapshot, I was impressed. It didn’t take up a lot of space, and it quietly did its job in the background. Here’s why I think it’s a great tool:
- Simple to set up
You don’t need to be a Linux wizard. - Fast backups
It uses hard links, so it avoids copying the same files again. - Safe from “oops” moments
You can recover files even after you mess something up.
Compared to manually copying files with a USB stick, rsnapshot is like having a smart assistant who never forgets.
What You’ll Need
Before we jump in, make sure you have:
- A Linux system (Ubuntu, Debian, CentOS, or anything similar)
rsnapshot
installed- Some disk space for the backups
- A source (where your files are) and a destination (where the backups go)
If you’re not sure how much space you need, think about how big your Documents, Pictures, and important folders are. rsnapshot saves space by only storing changes, but it’s still good to have some wiggle room.
Step-by-Step: Setting Up rsnapshot
Let’s walk through it step by step. I’ll explain what each step does and why it matters.
1. Install rsnapshot
On Debian or Ubuntu:
sudo apt update
sudo apt install rsnapshot
On CentOS:
sudo yum install rsnapshot
On Fedora:
sudo dnf install rsnapshot
2. Edit the Config File
The config file tells rsnapshot what to do and when to do it.
Open it using:
sudo nano /etc/rsnapshot.conf
You’ll see a lot of lines. Don’t panic. We only need to change a few things.
Change the Backup Directory
Find this line:
snapshot_root /var/cache/rsnapshot/
Change it to wherever you want your backups to go, like:
snapshot_root /backup/
I use /backup
because it’s easy to remember. Make sure that folder exists and has enough space.
Set the Intervals
You’ll see lines like:
interval hourly 6
interval daily 7
interval weekly 4
interval monthly 3
This means:
- Keep 6 hourly backups
- Keep 7 daily backups
- Keep 4 weekly backups
- Keep 3 monthly backups
Feel free to change these numbers. I only use daily and weekly, to keep things simple.
Add Your Backup Paths
Scroll to the bottom, and you’ll see lines that start with backup
.
Here’s an example:
backup /home/yourname/Documents/ localhost/
This means: copy files from /home/yourname/Documents
and save them under the localhost
folder in your backup directory.
You can add as many folders as you want. Here are a few more examples:
backup /etc/ localhost/
backup /var/www/ localhost/
Just make sure there’s a space between the source and the destination.
3. Test Your Config File
Before running anything, check your config file for errors:
sudo rsnapshot configtest
If it says “Syntax OK,” you’re good to go. If it gives an error, check for missing spaces or typos. I made that mistake more than once.
How to Run a Backup
To run a backup manually, just type:
sudo rsnapshot daily
You can also run:
sudo rsnapshot weekly
This will start a backup using the rules you set in the config file. Try it once and see what it does.
Set It to Run Automatically (Cron Jobs)
You probably don’t want to run this by hand every day. I didn’t either.
That’s where cron comes in. Cron is a scheduler—it runs things at set times.
To open the cron list:
sudo crontab -e
Add a line like this to run your daily backup at 2am:
0 2 * * * /usr/bin/rsnapshot daily
Let me explain the numbers:
0 2
= 2:00 AM* * *
= every day, every month, every weekday
If you want a weekly backup on Sunday at 3am:
0 3 * * 0 /usr/bin/rsnapshot weekly
Just make sure the path to rsnapshot
is correct. You can check it with:
which rsnapshot
What Happens Behind the Scenes?
rsnapshot uses hard links to make backups efficient. That means if a file hasn’t changed, it doesn’t get copied again. It just creates a pointer to the old version.
This is great because:
- It saves disk space
- Backups run faster
- You can still recover files easily
It’s like cloning a file, but without taking up twice the space. Pretty neat, right?
Example Use Case (My Setup)
Here’s what I personally back up every night:
backup /home/me/Documents/ localhost/
backup /etc/ localhost/
backup /srv/web/ localhost/
I store it in /backup
, which is mounted on a second hard drive.
I keep:
- 7 daily backups
- 4 weekly backups
It’s been running for over a year without problems. I even tested it by deleting a file on purpose (don’t worry—I had a copy). rsnapshot brought it back in seconds.
Some Handy Tips
Here are a few things I learned the hard way:
- Always test first
Runrsnapshot configtest
before setting it on autopilot. - Use a second drive
Don’t store backups on the same disk you’re backing up. - Check disk space
Usedf -h
to see how much space is left.
And here’s a fun one:
- Label your backup folders
Otherwise, you might end up with “backup of backup of backup” syndrome.
Benefits of Using rsnapshot
Just to sum it up, here’s why I stick with rsnapshot:
- Peace of mind
If I mess up a file, I can recover it. - Lightweight
It doesn’t slow down my system. - Low maintenance
Once it’s set up, it just works.
Common Mistakes to Avoid
Here’s a quick list of common “oops” moments:
- Forgetting to run
chmod
or create backup folder - Editing config file without keeping a backup
- Running out of space due to too many snapshots
Double-check things as you go. Backing up your backup plan is always smart.
Final Thoughts
Setting up rsnapshot might sound scary at first, but once you try it, you’ll see it’s not too bad. Think of it like a digital seatbelt. You might not need it every day, but when you do—it’s a lifesaver.
If you ever feel like giving up, just remember: “Every byte you save is a byte you don’t have to bite later.”
So, ready to give rsnapshot a shot? You might say it’s a snap.