dsnap-sync: make btrfs_quota usage an option
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -53,6 +53,7 @@ exec 3>$PIPE 4>$BTRFS_PIPE
|
||||
args=
|
||||
answer=no
|
||||
batch=0
|
||||
btrfs_quota=0
|
||||
color=0
|
||||
donotify=0
|
||||
dryrun=0
|
||||
@@ -179,7 +180,7 @@ create_snapshot () {
|
||||
snapper_source_snapshot=$SUBVOLUME/.snapshots/$snapper_source_id/snapshot
|
||||
snapper_source_info=$SUBVOLUME/.snapshots/$snapper_source_id/info.xml
|
||||
|
||||
btrfs quota enable $snapper_source_snapshot
|
||||
#btrfs quota enable $snapper_source_snapshot
|
||||
sync
|
||||
|
||||
if [ $verbose -ge 3 ]; then
|
||||
@@ -741,6 +742,10 @@ parse_params () {
|
||||
uuid_cmdline="$2"
|
||||
shift 2
|
||||
;;
|
||||
--use-btrfs-quota)
|
||||
btrfs_quota=1
|
||||
shift 1
|
||||
;;
|
||||
-v|--verbose)
|
||||
verbose=$(($verbose + 1))
|
||||
shift 1
|
||||
@@ -909,6 +914,7 @@ parse_params () {
|
||||
if [ $dryrun -eq 1 ]; then snap_sync_options="${snap_sync_options} dry-run=true"; fi
|
||||
if [ $donotify -eq 1 ]; then snap_sync_options="${snap_sync_options} donotify=true"; fi
|
||||
if [ $color -eq 1 ]; then snap_sync_options="${snap_sync_options} color=true"; fi
|
||||
if [ $btrfs_quota -eq 1 ]; then snap_sync_options="${snap_sync_options} use-btrfs-quota=true"; fi
|
||||
if [ $batch -eq 1 ]; then
|
||||
snap_sync_options="${snap_sync_options} batch=true do_pv_cmd=$do_pv_cmd"
|
||||
else
|
||||
@@ -919,7 +925,6 @@ parse_params () {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
quote_args () {
|
||||
# quote command in ssh call to prevent remote side from expanding any arguments
|
||||
# using dash's buildin printf
|
||||
@@ -1165,6 +1170,7 @@ run_backup () {
|
||||
"$snapper_source_id" "$snapper_source_snapshot"
|
||||
fi
|
||||
|
||||
if [ $btrfs_quota -eq 1 ]; then
|
||||
# qgroup for given path, exclude ancestrals
|
||||
# qgroup identifiers conform to level/id where level 0 is reserved to the qgroups associated with subvolumes
|
||||
snapper_source_snapshot_size=$(eval btrfs qgroup show -f --raw $snapper_source_snapshot 2>/dev/null \
|
||||
@@ -1192,10 +1198,15 @@ run_backup () {
|
||||
|
||||
# should we disable quota usage again?
|
||||
#if [ $btrfs_quota_tmp -eq 1 ]; then btrfs quota disable $snapper_source_snapshot; fi
|
||||
|
||||
#snapper_source_snapshot_size=$(du --sum $snapper_source_snapshot 2>/dev/null \
|
||||
# | awk -F ' ' '{print $1}')
|
||||
#snapper_source_snapshot_size=$(($snapper_source_snapshot_size / 1024 / 1024))G
|
||||
else
|
||||
snapper_source_snapshot_size=$(du --sum $snapper_source_snapshot 2>/dev/null \
|
||||
| awk -F ' ' '{print $1}')
|
||||
snapper_source_snapshot_size=$(($snapper_source_snapshot_size / 1024 / 1024))G
|
||||
if [ $verbose -ge 2 ]; then
|
||||
printf "${MAGENTA}BTRFS subvolume size for ${GREEN}source snapshot${MAGENTA}: id=${GREEN}'%s'${MAGENTA}, size=${GREEN}'%s'${NO_COLOR} ...\n" \
|
||||
"$snapper_source_id" "$snapper_source_snapshot_size"
|
||||
fi
|
||||
fi
|
||||
|
||||
# settings for interactive progress status
|
||||
if [ $do_pv_cmd -eq 1 ]; then
|
||||
@@ -1506,7 +1517,8 @@ run_finalize () {
|
||||
if [ $verbose -ge 3 ]; then
|
||||
printf "${MAGENTA}Tagging snapper metadata${NO_COLOR} for snapper id ${GREEN}'%s'${NO_COLOR} on source for configuration ${GREEN}'%s'${NO_COLOR} ...\n" \
|
||||
"$snapper_source_id" "$selected_config"
|
||||
printf "calling: '%s'\n" "$(eval $cmd)"
|
||||
# printf "calling: '%s'\n" "$(eval $cmd)"
|
||||
printf "calling: '%s'\n" "$cmd"
|
||||
fi
|
||||
ret=$(eval "$cmd")
|
||||
if [ $verbose -ge 3 ]; then
|
||||
@@ -1522,7 +1534,7 @@ run_finalize () {
|
||||
if [ $verbose -ge 3 ]; then
|
||||
printf "${MAGENTA}Tagging snapper metadata${NO_COLOR} for snapper sync id ${GREEN}'%s'${NO_COLOR} on source for configuration ${GREEN}'%s'${NO_COLOR} ...\n" \
|
||||
"$snapper_source_sync_id" "$selected_config"
|
||||
printf "calling: '%s'\n" "$(eval $cmd)"
|
||||
printf "calling: '%s'\n" "$cmd"
|
||||
fi
|
||||
ret=$(eval "$cmd")
|
||||
snapper_source_sync_snapshot=$SUBVOLUME/.snapshots/$snapper_source_sync_id/snapshot
|
||||
@@ -1540,7 +1552,7 @@ run_finalize () {
|
||||
fi
|
||||
|
||||
if [ $verbose -ge 1 ]; then
|
||||
printf "Backup complete: id=${GREEN}'%s'${NOCOLOR}, config=${GREEN}'%s'${NOCOLOR}\n" \
|
||||
printf "Backup complete: id=${GREEN}'%s'${NO_COLOR}, config=${GREEN}'%s'${NO_COLOR}\n" \
|
||||
"$snapper_source_id" "$selected_config"
|
||||
fi
|
||||
done
|
||||
@@ -1714,6 +1726,7 @@ Usage: $progname [options]
|
||||
Options:
|
||||
-a, --automount <path> start automount for given path to get a valid target mountpoint.
|
||||
-b, --backupdir <prefix> backupdir is a relative path that will be appended to target backup-root
|
||||
--use-btrfs-quota use btrfs-quota to calculate snapshot size
|
||||
-d, --description <desc> Change the snapper description. Default: "latest incremental backup"
|
||||
--label-finished <desc> snapper description tagging successful jobs. Default: "dsnap-sync backup"
|
||||
--label-running <desc> snapper description tagging active jobs. Default: "dsnap-sync in progress"
|
||||
|
||||
Reference in New Issue
Block a user