From 1b2a164a21b7a31ff9625388b392eb0c2780b227 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 17 Jan 2010 14:09:02 -0500 Subject: Add option to manually resquash down to MIN_BINS --- squashfu | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/squashfu b/squashfu index e111245..7aac148 100755 --- a/squashfu +++ b/squashfu @@ -21,7 +21,7 @@ die () { } create_new_squash () { -# Args: number of bins to be squashed (as determined by check_for_resquash), -1 on initial creation +# Args: number of bins to be squashed, -1 on initial creation # Returns: 0 on success, non-zero on failure # If making first seed, create it directly from source @@ -332,6 +332,25 @@ action_report () { "$(du -csh "$BINS_DIR" "$SEED" 2>/dev/null | grep -E "total$" | awk '{print $1}')" } +action_resquash_now () { +# Args: none +# Returns: none + + if [[ $UID -ne 0 ]]; then + die "Must be root to perform a resquash" + fi + + info "Voluntary resquash requested" + + local number_of_bins=$(grep -vE "^[ ]*$" "$BINVENTORY" | wc -l) + if [[ $number_of_bins -le $MIN_BINS ]]; then + die "Nothing to do. Current backups do not exceed MIN_BINS value." + else + create_new_squash $[ $number_of_bins - $MIN_BINS ] + fi + +} + usage () { info "SquashFu: Super Awesome Backup Express (Professional Edition)" echo "version: $VER" @@ -344,6 +363,10 @@ ACTIONS -B Runs a regular backup, using the config file at /etc/squashfu. + -C + Create a new squash by merging old bins. This will still leave you + with $MIN_BINS backups (as per the MIN_BINS setting in your config. + -Q Displays the size of the seed, the incrementals, and totals. @@ -361,6 +384,7 @@ HELP case $1 in "-B") action_backup ;; + "-C") action_resquash_now ;; "-Q") action_report ;; "-R") shift; action_rollback $1 ;; "-U") unmount_all ;; -- cgit v1.2.3