mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-22 11:11:39 +00:00
Compare commits
4 Commits
9fe6678b95
...
d6abf65df9
| Author | SHA1 | Date | |
|---|---|---|---|
| d6abf65df9 | |||
| 5e695db2a3 | |||
| 3d20c135c5 | |||
| e28367db0d |
@ -21,12 +21,14 @@ COPYFLAGS=$RSYNCFLAGS
|
|||||||
# XXX need to test if this exists...
|
# XXX need to test if this exists...
|
||||||
VERIFY=jdupes
|
VERIFY=jdupes
|
||||||
VERIFYFLAGS="-r -u -I"
|
VERIFYFLAGS="-r -u -I"
|
||||||
DO_VERIFY=1
|
DO_VERIFY=
|
||||||
|
|
||||||
|
|
||||||
COMPRESS=./compress-archive.sh
|
COMPRESS=./compress-archive.sh
|
||||||
DO_COMPRESS=1
|
DO_COMPRESS=1
|
||||||
|
|
||||||
|
SNAPSHOT=../../../../snapshot.sh
|
||||||
|
|
||||||
|
|
||||||
# Config file to contain all the default settings...
|
# Config file to contain all the default settings...
|
||||||
# XXX not sure if this is a good idea...
|
# XXX not sure if this is a good idea...
|
||||||
@ -352,6 +354,11 @@ if [[ $DO_COMPRESS ]] ; then
|
|||||||
echo "Compressing archive: done."
|
echo "Compressing archive: done."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
##if ! [ -z "$SNAPSHOT" ] \
|
||||||
|
## && [ -e "$SNAPSHOT" ] ; then
|
||||||
|
## "$SNAPSHOT"
|
||||||
|
##fi
|
||||||
|
|
||||||
# XXX add report...
|
# XXX add report...
|
||||||
# XXX
|
# XXX
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
SNAPSHOT_DIR=.snapshots
|
SNAPSHOT_DIR=.snapshots
|
||||||
SUBVOLUME_DIR=media
|
SUBVOLUME_DIR=media
|
||||||
|
SNAPSHOT_COUNT=5
|
||||||
|
|
||||||
|
|
||||||
# run in script dir (not cwd)...
|
# run in script dir (not cwd)...
|
||||||
@ -29,13 +30,11 @@ fi
|
|||||||
|
|
||||||
# check if on btrfs filesystem...
|
# check if on btrfs filesystem...
|
||||||
# XXX also check if btrfs command is available...
|
# 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
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#SNAPSHOT_COUNT=
|
|
||||||
|
|
||||||
|
|
||||||
# create ./media...
|
# create ./media...
|
||||||
# XXX check if not a directory...
|
# XXX check if not a directory...
|
||||||
@ -44,7 +43,7 @@ if ! [ -e "$SUBVOLUME_DIR" ] ; then
|
|||||||
# XXX build tree -- ImageGrid
|
# XXX build tree -- ImageGrid
|
||||||
|
|
||||||
# convert ./media to a subvolume...
|
# convert ./media to a subvolume...
|
||||||
elif [ "$(stat --format=%i "$SUBVOLUME_DIR")" == 256 ] ; then
|
elif ! [ "$(stat --format=%i "$SUBVOLUME_DIR")" == 256 ] ; then
|
||||||
mkdir bak
|
mkdir bak
|
||||||
mv "$SUBVOLUME_DIR" bak/
|
mv "$SUBVOLUME_DIR" bak/
|
||||||
btrfs subvolume create "$SUBVOLUME_DIR"
|
btrfs subvolume create "$SUBVOLUME_DIR"
|
||||||
@ -58,12 +57,30 @@ mkdir -p "$SNAPSHOT_DIR"
|
|||||||
# XXX should this be more human readable???
|
# XXX should this be more human readable???
|
||||||
# ...a date + number maybe???
|
# ...a date + number maybe???
|
||||||
SNAPSHOT=$((
|
SNAPSHOT=$((
|
||||||
$( ls "$SNAPSHOT_DIR" \
|
$( ls "$SNAPSHOT_DIR/" \
|
||||||
| sort -n \
|
| sort -n \
|
||||||
| tail -n 1 ) \
|
| tail -n 1 ) \
|
||||||
+ 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user