rsnapshot 1.4.5 on AWS User Guide
No longer open to new subscribers. The AWS Marketplace listing this guide was written for is closed to new subscriptions. If you already run it, your instances and this guide are unaffected. For what you can launch today, see rsnapshot.
Overview
This guide covers launching and using the rsnapshot 1.4.5 on Ubuntu 24.04 AMI from cloudimg on Amazon EC2. It is one version of the cloudimg backup and recovery listing on AWS Marketplace; you pick it as the software version when you subscribe and launch.
rsnapshot is an open source filesystem snapshot utility built on rsync. Each run copies only what changed since the last snapshot and hard-links every unchanged file to the previous one, so a week of daily snapshots costs little more than one full copy. Each snapshot is a plain directory tree: you restore a file with cp.
The cloudimg image is a ready to run backup server:
- Backups from the first boot.
alphasnapshots every 4 hours (6 kept),betadaily (7 kept) andgammaweekly (4 kept) of/etc,/home,/root,/var/logand the cron spool, driven by systemd timers. - A volume of their own. Snapshots go to
/srv/rsnapshot/snapshotson a separate 20 GiB gp3 EBS volume, never the root disk. A scheduled run refuses to start if that volume is not mounted, and launching with a bigger volume gives you more room: first boot grows the filesystem to fit. - Pull backups from your other servers. First boot generates an SSH key unique to the instance and writes its public half to a root only note; trust it on a server and add one line to the config.
- Patched rsync. Ubuntu 24.04's rsync 3.2.7 does not have the rsync 3.5.0 security fixes, which matter here because a backup server receives files from the machines it backs up. The image runs rsync 3.5.1 built from the signed upstream release instead, and Ubuntu's rsync package is removed and blocked.
- Locked down. The backup services cannot reach the instance metadata service and run under systemd sandboxing; the AMI requires IMDSv2, SSH accepts keys only, and nothing listens on the network except SSH.
What is on the image: rsnapshot 1.4.5 and rsnapshot-diff (/usr/local/bin, built unmodified from the upstream release), rsync 3.5.1 (/usr/local/bin/rsync, also /usr/bin/rsync), their licences and source in /usr/local/share/doc/rsnapshot and /usr/local/share/doc/rsync, fully patched Ubuntu 24.04 LTS with unattended security upgrades, cloud-init and the AWS Systems Manager agent.
Default user: ubuntu · Architecture: x86_64 · Recommended instance type: m5.large
Prerequisites
- An AWS account subscribed to the listing, an EC2 key pair and a VPC subnet.
- A security group that allows TCP 22 (SSH) from your own networks only. rsnapshot opens no port of its own.
- To back up other servers: SSH from this instance to them, and root (or a user that can read the data) on each.
Step 1: Launch the instance
In the AWS Marketplace listing choose Continue to Subscribe, then Continue to Configuration, pick rsnapshot 1.4.5 on Ubuntu 24.04 as the software version and your Region, then Launch through EC2. Choose m5.large (a smaller type is fine for the instance's own files), your key pair and a security group as above. The AMI attaches the 20 GiB snapshot volume automatically; in the launch wizard's storage section you can make it larger to keep more history.
With the AWS CLI (replace the values in angle brackets):
aws ec2 run-instances --region <region> --image-id <ami-id-from-the-listing> \
--instance-type m5.large --key-name <your-key-pair> \
--security-group-ids <your-security-group> --subnet-id <your-subnet> \
--metadata-options HttpTokens=required,HttpEndpoint=enabled \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=rsnapshot}]'
Step 2: Connect to your instance
| Version | SSH user |
|---|---|
| rsnapshot 1.4.5 on Ubuntu 24.04 | ubuntu |
ssh -i <your-key.pem> ubuntu@<public-ip>
Step 3: Check the schedule and the snapshot volume
First boot prepares the snapshot volume and generates the instance's SSH key. The three timers then run the backups:
systemctl is-active rsnapshot-alpha.timer rsnapshot-beta.timer rsnapshot-gamma.timer
sudo test -f /var/lib/cloudimg/rsnapshot-firstboot.done && echo FIRSTBOOT_DONE
systemctl list-timers 'rsnapshot-*' --no-legend | awk '{print $NF}' | sort
active
active
active
FIRSTBOOT_DONE
rsnapshot-alpha.service
rsnapshot-beta.service
rsnapshot-gamma.service
alpha runs every 4 hours, beta daily at 03:30 UTC and gamma on Mondays at 04:30 UTC, each up to 15 minutes later at random. A run missed while the instance was stopped happens at the next boot.
The snapshot volume:
findmnt -n -o TARGET,FSTYPE,SIZE /srv/rsnapshot
sudo ls -ld /srv/rsnapshot/snapshots | awk '{print $1, $3, $NF}'
/srv/rsnapshot ext4 19.5G
drwx------ root /srv/rsnapshot/snapshots
Only SSH listens on the network:
sudo ss -lntp | awk 'NR>1 {print $4, $6}' | sed -E 's/pid=[0-9]+,fd=[0-9]+/.../g' | sort
0.0.0.0:22 users:(("sshd",...),("systemd",...))
127.0.0.53%lo:53 users:(("systemd-resolve",...))
127.0.0.54:53 users:(("systemd-resolve",...))
[::]:22 users:(("sshd",...),("systemd",...))
Step 4: Read the instance details
First boot writes the instance's details to /root/rsnapshot-instance.txt (root only). rsnapshot has no login and no password; the only secret is the private SSH key the note points to:
sudo cat /root/rsnapshot-instance.txt
# rsnapshot 1.4.5 - generated on first boot by rsnapshot-firstboot.service
# rsnapshot has no login, no password and no network port. The SSH key below is unique to this instance (none was
# baked into the image); its private half (/root/.ssh/id_rsnapshot, 0600 root) lets this instance PULL backups from hosts that trust
# the public half. Keep it secret.
#
RSNAPSHOT_CONFIG=/etc/rsnapshot.conf
RSNAPSHOT_SNAPSHOT_ROOT=/srv/rsnapshot/snapshots/
RSNAPSHOT_DATA_DEVICE=/dev/nvme1n1
RSNAPSHOT_SSH_KEY=/root/.ssh/id_rsnapshot
RSNAPSHOT_KEY_FINGERPRINT=<RSNAPSHOT_KEY_FINGERPRINT>
RSNAPSHOT_PUBLIC_KEY=ssh-ed25519 <this instance's public key> rsnapshot@<instance-id>
#
# Schedules: systemctl list-timers 'rsnapshot-*' Check the config: sudo rsnapshot configtest
# Self test: sudo rsnapshot-selftest.sh Snapshots: sudo ls /srv/rsnapshot/snapshots
# Remote pull: add the RSNAPSHOT_PUBLIC_KEY line to /root/.ssh/authorized_keys on the source host, then add a line
# backup<TAB>root@<source-host>:/etc/<TAB><source-host>/ to /etc/rsnapshot.conf and run sudo rsnapshot configtest
# User guide: https://www.cloudimg.co.uk/guides/rsnapshot-1-4-5-on-ubuntu-24-04-aws/
Your instance shows its own device, fingerprint and public key.
| Value | Used for |
|---|---|
RSNAPSHOT_CONFIG |
The configuration file (Step 6) |
RSNAPSHOT_SNAPSHOT_ROOT |
Where the snapshots are (Step 7) |
RSNAPSHOT_DATA_DEVICE |
The EBS volume that holds them (Step 10) |
RSNAPSHOT_SSH_KEY |
The private key rsnapshot uses to pull from other servers (Step 9) |
RSNAPSHOT_KEY_FINGERPRINT, RSNAPSHOT_PUBLIC_KEY |
The key's SHA-256 fingerprint, and the line to add to a source server's authorized_keys |
Step 5: Run the self test
rsnapshot-selftest.sh proves the backup cycle on this instance without touching your snapshots: it checks the versions and the shipped configuration, then in a throwaway directory on the snapshot volume takes two snapshots and checks that the backup holds the files, that the snapshots rotate, that an unchanged file is hard-linked between them while a changed file keeps both versions, and that a deleted file restores byte for byte. It removes everything it made:
sudo rsnapshot-selftest.sh
RSNAPSHOT_SELFTEST_OK rsnapshot 1.4.5 + rsync 3.5.1; shipped config Syntax OK; backup populated; second run rotated alpha.0/alpha.1 with the unchanged file hard-linked (inode 524303, 2 links) and the changed file versioned; restore matched
Step 6: The configuration
/etc/rsnapshot.conf separates fields with tabs, not spaces. This shows the active lines with each tab as ^I:
sudo rsnapshot configtest
grep -v -e '^#' -e '^$' /etc/rsnapshot.conf | cat -T
Syntax OK
config_version^I1.2
snapshot_root^I/srv/rsnapshot/snapshots/
no_create_root^I1
cmd_cp^I/usr/bin/cp
cmd_rm^I/usr/bin/rm
cmd_rsync^I/usr/local/bin/rsync
cmd_ssh^I/usr/bin/ssh
cmd_logger^I/usr/bin/logger
cmd_du^I/usr/bin/du
retain^Ialpha^I6
retain^Ibeta^I7
retain^Igamma^I4
verbose^I2
loglevel^I3
logfile^I/var/log/rsnapshot.log
lockfile^I/run/rsnapshot.pid
ssh_args^I-i /root/.ssh/id_rsnapshot -o IdentitiesOnly=yes -o BatchMode=yes
exclude^I/srv/rsnapshot/**
backup^I/etc/^Ilocalhost/
backup^I/home/^Ilocalhost/
backup^I/root/^Ilocalhost/
backup^I/var/log/^Ilocalhost/
backup^I/var/spool/cron/^Ilocalhost/
retainsets how many snapshots of each level are kept. Eachbetarun promotes the oldestalphasnapshot, eachgammarun the oldestbeta.- A
backupline (backup, a tab, the source, a tab, the destination) adds a path. A trailing slash on the source backs up its contents; the destination is a directory name inside each snapshot. no_create_root 1makes rsnapshot refuse to run if the snapshot volume is missing, so a snapshot never lands on the root disk.
Edit with sudo nano /etc/rsnapshot.conf, keep the tabs, and check the result with sudo rsnapshot configtest before the next scheduled run.
Step 7: Take a snapshot and restore a file
Run an alpha snapshot now through the same service the timer uses (it checks the snapshot volume first and takes the shared lock):
sudo systemctl start rsnapshot-alpha.service
systemctl show -p Result --value rsnapshot-alpha.service
sudo ls /srv/rsnapshot/snapshots/ /srv/rsnapshot/snapshots/alpha.0/localhost/
sudo tail -1 /var/log/rsnapshot.log
success
/srv/rsnapshot/snapshots/:
alpha.0
/srv/rsnapshot/snapshots/alpha.0/localhost/:
etc
home
root
var
The last log line ends alpha: completed successfully. alpha.0 is always the newest snapshot, alpha.1 the one before, and so on. Every snapshot is a complete tree you can read like any directory. To restore a file, copy it back:
sudo ls -l /srv/rsnapshot/snapshots/alpha.0/localhost/etc/hostname
sudo cp -a /srv/rsnapshot/snapshots/alpha.0/localhost/etc/hostname /tmp/hostname.restored
sudo cmp /etc/hostname /tmp/hostname.restored && echo RESTORED_MATCHES
sudo rm -f /tmp/hostname.restored
RESTORED_MATCHES
To see how much space the snapshots use (hard-linked files are counted once):
sudo du -sh /srv/rsnapshot/snapshots
df -h /srv/rsnapshot | tail -1
Step 8: Check the security posture
The backup services keep network access (they pull from your servers over SSH) but cannot reach the instance metadata service; the first boot service has no network access at all:
systemctl show -p IPAddressDeny --value rsnapshot-alpha.service | tr ' ' '\n' | sort
systemctl show -p NoNewPrivileges -p PrivateTmp -p ProtectKernelTunables rsnapshot-alpha.service
168.63.129.16/32
169.254.169.254/32
fd00:ec2::254/128
NoNewPrivileges=yes
PrivateTmp=yes
ProtectKernelTunables=yes
rsync on this image is the upstream 3.5.1 build, and apt cannot bring back Ubuntu's older rsync package:
rsync --version | sed -n 1p
readlink -f /usr/bin/rsync
apt-cache policy rsync | sed -n 1,3p
rsync version 3.5.1 protocol version 33
/usr/local/bin/rsync
rsync:
Installed: (none)
Candidate: (none)
The SSH key and the note are root only, and the key's fingerprint matches the note:
sudo stat -c '%a %U %n' /root/.ssh/id_rsnapshot /root/.ssh/id_rsnapshot.pub /root/rsnapshot-instance.txt
sudo ssh-keygen -lf /root/.ssh/id_rsnapshot.pub | awk '{print $2}'
600 root /root/.ssh/id_rsnapshot
644 root /root/.ssh/id_rsnapshot.pub
600 root /root/rsnapshot-instance.txt
<RSNAPSHOT_KEY_FINGERPRINT>
Step 9: Back up another server
rsnapshot pulls: this instance connects to each source server over SSH and copies from it. On the source server, as root, add this instance's public key (the RSNAPSHOT_PUBLIC_KEY value from Step 4) as one line in /root/.ssh/authorized_keys, limited to this instance's address:
from="<this instance's private IP>" ssh-ed25519 <this instance's public key> rsnapshot@<instance-id>
The source server needs rsync installed (any 3.x; keep it patched) and must allow SSH from this instance in its security group. Then, on this instance, connect once with the key (this also records the server's host key) and add a backup line with tabs between the fields; replace <private-ip> with the source server's private IP address:
sudo ssh -i /root/.ssh/id_rsnapshot root@<private-ip> true
printf 'backup\troot@<private-ip>:/etc/\t<private-ip>/\n' | sudo tee -a /etc/rsnapshot.conf
sudo rsnapshot configtest
The next scheduled run includes the server, under /srv/rsnapshot/snapshots/alpha.0/<private-ip>/. A server that cannot be reached makes that run end with an error in /var/log/rsnapshot.log, so check the log after adding one.
Step 10: Grow the snapshot volume
Increase the data volume's size in the EC2 console (Volumes, Modify volume) or with aws ec2 modify-volume, wait until its state is optimizing or completed, then grow the filesystem (online, no unmount needed):
D=$(sudo sed -n 's/^RSNAPSHOT_DATA_DEVICE=//p' /root/rsnapshot-instance.txt)
sudo resize2fs "$D"
df -h /srv/rsnapshot
Snapshots live on one EBS volume in one Availability Zone, so they do not protect against losing that volume: take EBS snapshots of the data volume too (for example with Amazon Data Lifecycle Manager), or copy the snapshot tree to another system.
Step 11: Server components
| Component | Path |
|---|---|
| rsnapshot, rsnapshot-diff | /usr/local/bin/rsnapshot, /usr/local/bin/rsnapshot-diff |
| rsync | /usr/local/bin/rsync (/usr/bin/rsync links to it) |
| Licences, source and written offer | /usr/local/share/doc/rsnapshot/, /usr/local/share/doc/rsync/ |
| Configuration | /etc/rsnapshot.conf |
| Snapshots | /srv/rsnapshot/snapshots/ on the data volume |
| Service units | rsnapshot-alpha, rsnapshot-beta, rsnapshot-gamma (.timer and .service), rsnapshot-firstboot.service, with cloudimg drop-ins in /etc/systemd/system/<unit>.d/ |
| Helpers | /usr/local/sbin/rsnapshot-run, rsnapshot-preflight, rsnapshot-selftest.sh |
| SSH key for pulls | /root/.ssh/id_rsnapshot (mode 0600) |
| Instance details | /root/rsnapshot-instance.txt (mode 0600) |
| Log | /var/log/rsnapshot.log, and sudo journalctl -u 'rsnapshot-*' |
rsnapshot version
ls /usr/local/share/doc/rsnapshot /usr/local/share/doc/rsync
rsnapshot 1.4.5-5-gaf84984
/usr/local/share/doc/rsnapshot:
COPYING
ChangeLog
SOURCE.txt
installed-binaries.sha256
rsnapshot-1.4.5.tar.gz
/usr/local/share/doc/rsync:
COPYING
NEWS.md
rsync-3.5.1.tar.gz
ubuntu-standard-deps.txt
The version string is the one upstream's 1.4.5 release tarball carries. Because rsync 3.5.1 replaces Ubuntu's rsync package, the ubuntu-standard metapackage (the only package that required it) was removed; everything it had installed is still installed and listed in ubuntu-standard-deps.txt.
Step 12: Security recommendations
- Allow port 22 in the security group from your own networks only.
- Treat
/root/.ssh/id_rsnapshotas a credential: on each source server restrict its line inauthorized_keyswithfrom="...", and remove the line when you stop backing that server up. - Keep a copy off the instance: EBS snapshots of the data volume, or a copy of the snapshot tree elsewhere.
- Check
sudo rsnapshot configtestafter every configuration change, and watch/var/log/rsnapshot.logorsystemctl status 'rsnapshot-*'from your monitoring. - Keep the operating system patched; unattended security upgrades are on. rsnapshot and rsync are built from upstream, so apt does not update them: cloudimg publishes a new image version for each upstream security release.
Support and licensing
rsnapshot is open source under the GNU GPL version 2 or later and rsync under the GNU GPL version 3 or later; there is no per user or per CPU licence fee. Both licences, the unmodified upstream source tarballs and a written source offer are in /usr/local/share/doc/rsnapshot/ and /usr/local/share/doc/rsync/. cloudimg is not affiliated with or endorsed by the rsnapshot or rsync projects. The AMI price covers cloudimg's hardening, first boot setup and support.
- Email: support@cloudimg.co.uk
- Website: https://www.cloudimg.co.uk
- Support: 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours