Linux Backups

Backup /etc and /var before system changes

Cheap insurance before apt dist-upgrade or manual config edits.

9 min read Beginner Updated 9 Jun 2026

Step-by-step guide

Work through each section in order. Stop when your issue is resolved — you do not need every step for every situation.

Warning

Use a sudo-capable account, keep shell history for audit, and back up critical paths before changing boot, SSH, or package state.

What you will achieve

Cheap insurance before apt dist-upgrade or manual config edits.

1) Create timestamped backup folder

sudo mkdir -p /root/backups/prechange-$(date +%F)

2) Archive /etc and selected /var data

sudo tar -czf /root/backups/prechange-$(date +%F)/etc.tar.gz /etc
sudo tar -czf /root/backups/prechange-$(date +%F)/var-www.tar.gz /var/www

3) Verify archive integrity

sudo tar -tzf /root/backups/prechange-$(date +%F)/etc.tar.gz | head

Related guides

backup etc linux