Skip to content

Instantly share code, notes, and snippets.

@valorad
Last active March 27, 2021 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valorad/fd306db9b7807ff12caa504e39bf3ae9 to your computer and use it in GitHub Desktop.
Save valorad/fd306db9b7807ff12caa504e39bf3ae9 to your computer and use it in GitHub Desktop.
Mount BTRFS volumes and make a read-only system volume BTRFS snapshot on backup volume
#!/bin/sh
set -e
# Snapshot @targetSubvolume to @storageSubvolume/path/to/checkpoints/folder
UUID='76186cef-780f-4a80-9c0f-19fcc3a53ee6'
targetSubvolumeName='@arch-root'
storageSubvolumeName='@workspace'
mountPath="/mnt/$UUID"
systemVolumePath="$mountPath/$targetSubvolumeName"
snapshotPath="$mountPath/$storageSubvolumeName/systemCenter/btrfs/checkpoints/"
mkdir -p $mountPath
mount --uuid $UUID $mountPath
mkdir -p $snapshotPath
btrfs subvol snapshot -r $systemVolumePath $snapshotPath/@arch-checkpoint-"$(date '+%Y%m%d-%s')"-RO
umount -R $mountPath
rm -R $mountPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment