Last active
June 21, 2020 07:17
-
-
Save paulproteus/86cce50095a7fd48264f6e6d4f85580f to your computer and use it in GitHub Desktop.
backup a volume
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eou pipefail | |
blockdev="$1" | |
name="$2" | |
TMP="$(mktemp -d /tmp/$(date -I).$2.XXXXXXXXXX )" | |
FILELIST="$TMP"/"$name".filelist.txt | |
# Make the blockdev available in /tmp/name | |
sudo cp -a "$blockdev" "$TMP"/"$name" | |
sudo chmod 664 "$TMP"/"$name" | |
# Mount it, and make a file list | |
sudo mkdir "$TMP"/"$name".mounted | |
sudo mount "$TMP"/"$name" "$TMP"/"$name".mounted | |
cd "$TMP"/"$name".mounted | |
sudo find . | sort --compress-program=gzip > "$FILELIST" | |
# Unmount | |
sudo umount "$TMP"/"$name".mounted | |
sudo rmdir "$TMP"/"$name".mounted | |
# Use archivemount, then gupload, for filelist | |
gupload "$FILELIST" | |
rm "$FILELIST" | |
# Upload image | |
gupload "$TMP"/"$name" | |
# Remove disk device | |
sudo rm "$TMP"/"$name" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment