1. Decide what must be recoverable
Separate application data, configuration, databases, secrets and operating-system state. A list of files is not a recovery plan: document the restore order, dependencies, credentials and acceptable recovery point.
2. Create a timestamped archive
sudo tar --acls --xattrs -czf /root/etc-$(date +%F-%H%M).tar.gz /etc sudo tar -tzf /root/etc-$(date +%F-%H%M).tar.gz | head
Store the generated filename in a variable so the archive can be verified without reconstructing its timestamp:
BACKUP="/root/etc-$(date +%F-%H%M%S).tar.gz" sudo tar --acls --xattrs -czf "$BACKUP" /etc sudo tar -tzf "$BACKUP" | head sudo sha256sum "$BACKUP"
3. Copy backups off the server
scp root@SERVER_IP:/root/etc-YYYY-MM-DD-HHMMSS.tar.gz ./
Run this from your trusted workstation and replace the filename exactly. Prefer a dedicated backup account and encrypted storage. Do not expose archives containing private keys or credentials.
4. Test extraction into a temporary directory
sudo mkdir -p /root/restore-test sudo tar -xzf /root/etc-backup.tar.gz -C /root/restore-test sudo find /root/restore-test/etc -maxdepth 2 -type f | head
Inspect the extracted structure and compare checksums or selected files. Never test restoration by extracting over live /etc.
5. Database consistency
For databases, use their supported dump or physical-backup tools. Copying live database files with a generic tar command may produce an inconsistent backup unless the database is quiesced or the storage snapshot is coordinated.
6. Apply the 3-2-1 principle
- Keep at least three copies of important data.
- Use at least two different storage types or systems.
- Keep one copy off-site or otherwise isolated.
7. Recovery drill
- Provision a clean test host or isolated VM.
- Retrieve the backup and verify its checksum.
- Restore configuration and data in documented order.
- Start services and test application-level health.
- Record elapsed recovery time and missing dependencies.
Checklist
- Define scope and recovery objectives.
- Copy data off-host.
- Verify checksums after transfer.
- Perform regular restore tests.
- Protect and expire old backups securely.
References & further reading
Commands are examples for a representative Ubuntu/Linux environment. Review paths, versions, access requirements and maintenance impact before applying them to production systems.