local/bin/btrfs-snap-all: Add option to run "git gc" on all .git folders.
parent
00c01f1e17
commit
46a77604b3
|
@ -9,13 +9,17 @@ Snapshot all Btrfs subvolumes older than 1 day to a read-only '.snapshots/SUBVOL
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
-n: No preview.
|
-n: No preview.
|
||||||
|
-g: Run "git gc" on all .git folders.
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
OPT_PREVIEW=true
|
OPT_PREVIEW=true
|
||||||
while getopts ":hn" opt; do
|
OPT_GIT_GC=false
|
||||||
|
while getopts ":ghn" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
|
g)
|
||||||
|
OPT_GIT_GC=true ;;
|
||||||
h)
|
h)
|
||||||
usage
|
usage
|
||||||
exit ;;
|
exit ;;
|
||||||
|
@ -29,12 +33,18 @@ done
|
||||||
|
|
||||||
shift $(($OPTIND - 1))
|
shift $(($OPTIND - 1))
|
||||||
|
|
||||||
|
git_gc() { # $1=rootdir
|
||||||
|
find "$1" -type d -name ".git" -print -exec git --git-dir {} gc \;
|
||||||
|
}
|
||||||
|
|
||||||
snap () { # $1=fs $2=subvol
|
snap () { # $1=fs $2=subvol
|
||||||
local fs=$1
|
local fs=$1
|
||||||
local subvol=$2
|
local subvol=$2
|
||||||
|
|
||||||
local choice=N
|
local choice=N
|
||||||
local last=$(find "$fs/.snapshots/$subvol" -maxdepth 1 | tail -1)
|
local last=$(find "$fs/.snapshots/$subvol" -maxdepth 1 | tail -1)
|
||||||
|
|
||||||
|
$OPT_GIT_GC && git_gc "$fs/subvol"
|
||||||
$OPT_PREVIEW && rmirror "$fs/$subvol" "$last"
|
$OPT_PREVIEW && rmirror "$fs/$subvol" "$last"
|
||||||
|
|
||||||
echo -n "==> Snapshot '$fs/${subvol}'? (y/N) "
|
echo -n "==> Snapshot '$fs/${subvol}'? (y/N) "
|
||||||
|
|
Loading…
Reference in New Issue