Created
April 20, 2023 13:14
-
-
Save ed-davies/eb866c85b7beb7baf0ed511551410eed to your computer and use it in GitHub Desktop.
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 -e | |
STAMP=$(date "+%Y-%m-%dT%H:%M:%S") | |
DEST=/media/ed/hitachi | |
MACHINE=$(uname -n) | |
TARGET=$DEST/$MACHINE | |
[ -d $TARGET ] || ( | |
mkdir $TARGET | |
mkdir $TARGET/0 | |
ln -s ../0 $TARGET/current | |
) | |
[ -L $TARGET/current ] || ( | |
echo Target directory $TARGET/current doesn\'t exist or isn\'t a symlink | |
false | |
) | |
for DIR in home etc usr/local | |
do | |
mkdir -p $TARGET/incomplete-$STAMP/$DIR | |
rsync -axv --link-dest=$TARGET/current/$DIR/ /$DIR/ $TARGET/incomplete-$STAMP/$DIR/ | |
done | |
mv $TARGET/incomplete-$STAMP $TARGET/back-$STAMP | |
rm -f $TARGET/current | |
ln -s back-$STAMP $TARGET/current | |
ls -l $TARGET | |
df -h $DEST | |
umount $DEST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment