Backup PNETLABs using Timeshift

Category >
sync

apt-get update
apt-get install -y software-properties-common sshfs rsync gzip

add-apt-repository -y ppa:teejee2008/timeshift
apt-get update
apt-get install -y timeshift

Create a timeshift backup locally

ROOT_DEV=$(findmnt -n -o SOURCE /)

echo "Root device: $ROOT_DEV"

timeshift --create \
  --rsync \
  --snapshot-device "$ROOT_DEV" \
  --comments "PNETLab backup $(date '+%F %T')" \
  --scripted \
  --yes

Monitor the snapshot creation

watch -n 10 '
echo "=== Root filesystem ==="
df -h /
echo
echo "=== Timeshift snapshot size ==="
du -sh /run/timeshift/*/backup/timeshift/snapshots 2>/dev/null
echo
echo "=== Running processes ==="
ps -eo pid,stat,etime,%cpu,%mem,cmd | grep -E "[t]imeshift|[r]sync"
'

Once it is complete , list the snapshots

timeshift --list --snapshot-device "$ROOT_DEV"

ls -lah /timeshift/snapshots/2026-07-26_04-06-29
du -sh /timeshift/snapshots/2026-07-26_04-06-29

Zip and download

tar --acls --xattrs --numeric-owner -czpf \
/timeshift/snapshots/2026-07-26_04-06-29.tar.gz \
-C /timeshift/snapshots \
2026-07-26_04-06-29

Verify archive created

root@pnetlab:/timeshift/snapshots/2026-07-26_04-06-29# ls -lh /timeshift/snapshots/2026-07-26_04-06-29.tar.gz
-rw-r--r-- 1 root root 68G Jul 26 06:53 /timeshift/snapshots/2026-07-26_04-06-29.tar.gz

root@pnetlab:/timeshift/snapshots/2026-07-26_04-06-29# gzip -t /timeshift/snapshots/2026-07-26_04-06-29.tar.gz && echo "Archive is OK"
Archive is OK

Leave a Reply

Your email address will not be published. Required fields are marked *