A Bash-based, interactive, multi-server backup system using Restic, SSH, rsync, and MySQL/MariaDB dumps.
This toolkit allows you to:
- Back up multiple remote servers from a single machine
- Select which servers to back up interactively
- Dump MySQL/MariaDB databases safely
- Sync web application code only (filtered by file type)
- Store backups in separate Restic repositories
- Automatically prune old snapshots
- Mount backups using Restic FUSE for easy browsing
Backup Script:
- Interactive server selection (single or multiple)
- Per-server Restic repositories
- MySQL/MariaDB database dumps
- Supports multiple database on specific hosts
- rsync with file-type filtering
- Automatic restic unlock handling
- Snapshot retention policy:
- Daily: 7
- Weekly: 4
- Monthly: 6
- Detailed per-host logs
- Cron-safe (explicit PATH)
Mount Script:
- Interactive Restic mount menu
- Mount single or all repositories
- Automatic unmount if already mounted
- Clean mount structure per host
- Ideal for restore, inspection and audits
Install the following on the backup server:
sudo apt install -y restic rsync openssh-client mysql-client fuseEnsure:
- SSH key-based authentication to remote servers
- Restic repositories already accessible (local disk, NFS, S3, etc)
- FUSE enabled for mounting
1️⃣ Configure Servers
Edit backup/backup.sh
SERVERS=(
"host1;user1;web_dir1;db_name1;db_user1;db_pass1;restic_repo1;restic_password1"
"host2;user2;web_dir2;db_name2;db_user2;db_pass2;restic_repo2;restic_password2"
)Format:
"host;user;web_dir;db_name;db_user;db_pass;restic_repo;restic_password"2️⃣ Run Backup
chmod +x backup/backup.sh
./backup/backup.shExample prompt:
Available servers:
[0] host1
[1] host2
Enter the number(s) of the server(s) to back up (e.g., 0,1):3️⃣ Logs
Logs are written per host:
~/restic_logs/backup_<hostname>_<date>.logLogs older than 30 days are automatically removed.
See here for full script breakdown: BACKUP SCRIPT
1️⃣ Configure Mount Script
Edit mount/mount.sh:
SERVERS=(
"host1|/repo/host1|password"
"host2|/repo/host2|password"
)2️⃣ Run Mount Script
chmod +x mount/mount.sh
./mount/mount.shMenu example:
0) Mount ALL servers
1) host1
2) host2
q) Quit
Mounted locations:~/restic_mounts//
3️⃣ Unmount
fusermount -u ~/restic_mounts/host1🔄 Restore Examples
Restore latest snapshot
restic restore latest --target /restore/pathRestore specific snapshot
restic snapshots
restic restore <snapshot-id> --target /restore/pathSee here for full script breakdown: MOUNT SCRIPT