Compare commits

..

No commits in common. "d6abf65df9d44924b7e9bf413cf5a2938439b5b4" and "9fe6678b9521ad33b09ad16feada02b052acddb3" have entirely different histories.

2 changed files with 7 additions and 31 deletions

View File

@ -21,14 +21,12 @@ COPYFLAGS=$RSYNCFLAGS
# XXX need to test if this exists...
VERIFY=jdupes
VERIFYFLAGS="-r -u -I"
DO_VERIFY=
DO_VERIFY=1
COMPRESS=./compress-archive.sh
DO_COMPRESS=1
SNAPSHOT=../../../../snapshot.sh
# Config file to contain all the default settings...
# XXX not sure if this is a good idea...
@ -354,11 +352,6 @@ if [[ $DO_COMPRESS ]] ; then
echo "Compressing archive: done."
fi
##if ! [ -z "$SNAPSHOT" ] \
## && [ -e "$SNAPSHOT" ] ; then
## "$SNAPSHOT"
##fi
# XXX add report...
# XXX

View File

@ -19,7 +19,6 @@
SNAPSHOT_DIR=.snapshots
SUBVOLUME_DIR=media
SNAPSHOT_COUNT=5
# run in script dir (not cwd)...
@ -30,11 +29,13 @@ fi
# check if on btrfs filesystem...
# XXX also check if btrfs command is available...
if ! btrfs filesystem usage . > /dev/null 2>&1 ; then
if ! btrfs filesystem usage . > /dev/null ; then
exit
fi
#SNAPSHOT_COUNT=
# create ./media...
# XXX check if not a directory...
@ -43,7 +44,7 @@ if ! [ -e "$SUBVOLUME_DIR" ] ; then
# XXX build tree -- ImageGrid
# convert ./media to a subvolume...
elif ! [ "$(stat --format=%i "$SUBVOLUME_DIR")" == 256 ] ; then
elif [ "$(stat --format=%i "$SUBVOLUME_DIR")" == 256 ] ; then
mkdir bak
mv "$SUBVOLUME_DIR" bak/
btrfs subvolume create "$SUBVOLUME_DIR"
@ -57,30 +58,12 @@ mkdir -p "$SNAPSHOT_DIR"
# XXX should this be more human readable???
# ...a date + number maybe???
SNAPSHOT=$((
$( ls "$SNAPSHOT_DIR/" \
$( ls "$SNAPSHOT_DIR" \
| sort -n \
| tail -n 1 ) \
+ 1 ))
#btrfs subvolume snapshot -r "$SUBVOLUME_DIR" "${SNAPSHOT_DIR}/${SNAPSHOT}"
btrfs subvolume snapshot "$SUBVOLUME_DIR" "${SNAPSHOT_DIR}/${SNAPSHOT}"
if [[ $SNAPSHOT_COUNT =~ [0-9]* ]] \
&& [ "$SNAPSHOT_COUNT" != 0 ] ; then
SNAPSHOTS=($(\
ls "$SNAPSHOT_DIR/" \
| sort -n ))
remove=$(( ${#SNAPSHOTS[@]} - $SNAPSHOT_COUNT - 1 ))
while (( $remove >= 0 )) ; do
# XXX can we avoid sudo here???
# XXX is 'btrfs subvolume delete ...' the same as 'rm -rf ..'
#sudo btrfs subvolume delete -c ${SNAPSHOT_DIR}/${SNAPSHOTS[$remove]}
echo Removing snapshot: ${SNAPSHOT_DIR}/${SNAPSHOTS[$remove]}
rm -rf ${SNAPSHOT_DIR}/${SNAPSHOTS[$remove]}
remove=$(( $remove - 1 ))
done
fi
btrfs subvolume snapshot -r "$SUBVOLUME_DIR" "${SNAPSHOT_DIR}/${SNAPSHOT}"