Compare commits

...

4 Commits

Author SHA1 Message Date
d6abf65df9 added basic snapshot management....
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2025-02-02 18:18:27 +03:00
5e695db2a3 cleanup and fixes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2025-02-02 15:03:23 +03:00
3d20c135c5 Merge branch 'master' of github.com:flynx/ImageGrid 2025-02-02 14:52:20 +03:00
e28367db0d ...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2025-02-02 14:52:15 +03:00
2 changed files with 31 additions and 7 deletions

View File

@ -21,12 +21,14 @@ COPYFLAGS=$RSYNCFLAGS
# XXX need to test if this exists...
VERIFY=jdupes
VERIFYFLAGS="-r -u -I"
DO_VERIFY=1
DO_VERIFY=
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...
@ -352,6 +354,11 @@ if [[ $DO_COMPRESS ]] ; then
echo "Compressing archive: done."
fi
##if ! [ -z "$SNAPSHOT" ] \
## && [ -e "$SNAPSHOT" ] ; then
## "$SNAPSHOT"
##fi
# XXX add report...
# XXX

View File

@ -19,6 +19,7 @@
SNAPSHOT_DIR=.snapshots
SUBVOLUME_DIR=media
SNAPSHOT_COUNT=5
# run in script dir (not cwd)...
@ -29,13 +30,11 @@ fi
# check if on btrfs filesystem...
# XXX also check if btrfs command is available...
if ! btrfs filesystem usage . > /dev/null ; then
if ! btrfs filesystem usage . > /dev/null 2>&1 ; then
exit
fi
#SNAPSHOT_COUNT=
# create ./media...
# XXX check if not a directory...
@ -44,7 +43,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"
@ -58,12 +57,30 @@ 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 -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