Arch Linux Backup and Restore - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Arch Linux Backup and Restore Guide
Complete beginner-friendly guide to backing up and restoring your Arch Linux system, including file backups, system backups, automated backups, and restore procedures.
Table of Contents
Backup Strategies
What to Backup
Important data:
- Home directory (
/home) - Configuration files (
/etc) - Package lists
- System data
Backup Types
Types:
- Full backup: Entire system
- Incremental: Changes only
- File-level: Individual files
- Image backup: Disk image
File Backups
rsync
Install rsync:
# Install rsync
sudo pacman -S rsync
# Backup home directory
rsync -av --exclude='.cache' ~/ /backup/home/
# Restore
rsync -av /backup/home/ ~/
tar
Create archive:
# Backup home
tar -czf backup-home-$(date +%Y%m%d).tar.gz ~/
# Backup system
sudo tar -czf backup-system.tar.gz --exclude=/proc --exclude=/sys --exclude=/dev --exclude=/run --exclude=/tmp /
Restore tar
Extract archive:
# Extract
tar -xzf backup-home-20240115.tar.gz
# To specific location
tar -xzf backup-home-20240115.tar.gz -C /restore/path
System Backups
Clonezilla
Install Clonezilla:
# Download ISO from clonezilla.org
# Boot from ISO
# Follow wizard
dd
Disk image:
# Create image
sudo dd if=/dev/sda of=/backup/system.img bs=4M status=progress
# Restore
sudo dd if=/backup/system.img of=/dev/sda bs=4M status=progress
** Warning**: dd can destroy data if used incorrectly!
Timeshift
Install Timeshift:
# Install Timeshift
yay -S timeshift
# Create snapshot
sudo timeshift --create
# List snapshots
sudo timeshift --list
Automated Backups
Cron Jobs
Setup cron:
# Edit crontab
crontab -e
Example:
# Daily backup at 2 AM
0 2 * * * rsync -av ~/ /backup/home/
# Weekly full backup
0 3 * * 0 tar -czf /backup/weekly-$(date +\%Y\%m\%d).tar.gz ~/
systemd Timers
Create timer:
# Create service
sudo vim /etc/systemd/system/backup.service
Service file:
[Unit]
Description=Backup Service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/backup.sh
Create timer:
sudo vim /etc/systemd/system/backup.timer
Timer file:
[Unit]
Description=Backup Timer
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
Enable:
sudo systemctl enable backup.timer
sudo systemctl start backup.timer
Restore Procedures
Restore Files
From rsync:
# Restore
rsync -av /backup/home/ ~/
From tar:
# Extract
tar -xzf backup.tar.gz -C /
Restore System
From image:
# Boot from live USB
# Mount partitions
# Restore image
sudo dd if=backup.img of=/dev/sda
From Clonezilla:
# Boot Clonezilla
# Select restore
# Choose image
# Follow wizard
Backup Tools
BorgBackup
Install Borg:
# Install Borg
sudo pacman -S borg
# Create repository
borg init /backup/repo
# Create backup
borg create /backup/repo::archive-{now} ~/
# List archives
borg list /backup/repo
Restic
Install Restic:
# Install Restic
sudo pacman -S restic
# Initialize
restic init --repo /backup/repo
# Backup
restic backup ~/
# List snapshots
restic snapshots
Duplicity
Install Duplicity:
# Install Duplicity
sudo pacman -S duplicity
# Backup
duplicity ~/ file:///backup/home
# Restore
duplicity restore file:///backup/home ~/restore
Summary
This guide covered:
- Backup strategies - Planning backups
- File backups - rsync, tar
- System backups - Clonezilla, dd
- Automated backups - Cron, systemd
- Restore - Restore procedures
- Tools - Borg, Restic, Duplicity
Key Takeaways:
- Backup regularly
- Test restores
- Use automation
- Store backups off-site
- Document procedures
Next Steps
- Arch Linux System Configuration - System setup
- Arch Linux Filesystem Management - Filesystems
- ArchWiki Backup: https://wiki.archlinux.org/title/Backup_programs
This guide is based on the ArchWiki. For the most up-to-date information, always refer to the official ArchWiki.