Skip to content

Instantly share code, notes, and snippets.

@olavmrk
Last active December 2, 2020 07:47
Show Gist options
  • Save olavmrk/8560126 to your computer and use it in GitHub Desktop.
Save olavmrk/8560126 to your computer and use it in GitHub Desktop.
Archiving a server
# Copy the filesystem:
rsync --numeric-ids --checksum --delete --archive --verbose --exclude /dev --exclude /proc --exclude /run --exclude /sys root@someserver:/ /mnt/tmp
# Create a squashfs image
mksquashfs /mnt/tmp someserver.squashfs -comp xz -noappend
# Create LVM volume
lvcreate --size $(stat --format %s someserver.squashfs)B --name old-someserver vg
# Archive image on LVM
cat someserver.squashfs >/dev/vg/old-someserver
# Make LVM volume read only
lvchange --permission r /dev/vg/old-someserver
# Verify archive
mount /dev/vg/old-someserver /mnt/tmp
rsync --dry-run --numeric-ids --archive --delete --checksum --itemize-changes --exclude /dev --exclude /proc --exclude /run --exclude /sys root@someserver:/ /mnt/tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment