diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2019-08-13 14:41:46 +0100 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2019-08-13 14:42:24 +0100 |
commit | 0021e4ffd5a23a0ed38bce751904ea9d5e03b22e (patch) | |
tree | f1b0636bbae302680928aeb0f18d5278cb7f4679 /bin | |
parent | 259cd091ea424fe53bbee8c0253bc1e6a824db20 (diff) | |
download | dotfiles-0021e4ffd5a23a0ed38bce751904ea9d5e03b22e.tar.gz |
locmaint performs our full duplicity backups
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/locmaint | 27 | ||||
-rwxr-xr-x | bin/sysmaint | 15 | ||||
-rwxr-xr-x | bin/workstation-duplicity | 7 |
3 files changed, 31 insertions, 18 deletions
diff --git a/bin/locmaint b/bin/locmaint index 0c8427d7..3a82be5c 100755 --- a/bin/locmaint +++ b/bin/locmaint @@ -72,10 +72,11 @@ use Local::Homedir; use Local::Interactive qw(interactive_ensure_subroutine interactive_ensure_subroutine_success interactive_ensure_subroutine_no_output - get_ack + prompt_Yn get_ack ); use Local::MrRepo; use Local::ScriptStatus; +use Sys::Hostname; # CONFIG -- edit me @@ -102,6 +103,7 @@ sub main { do_homedir(); do_coldbkup(); + do_workstation_duplicity(); do_sysmaint(); # this is useful because we spawn so many interactive shells, and @@ -207,6 +209,29 @@ sub do_coldbkup { # Git::Wrapper to simplify existing code } +sub do_workstation_duplicity { + local $@; eval "use Date::Manip"; return if $@; + + my $profile = hostname() . "-" . getpwuid($<) . "-home"; + return unless -e "$ENV{HOME}/.duply/$profile/conf"; + + # Offer to force a full backup if it has been five days since the + # last. When running locmaint I often have a good connection and + # the time for that. If I run locmaint often enough, the duply + # cronjob can unconditionally do an incremental backup (which is + # good for roaming between WiFi networks) but the backup chain + # isn't in danger of growing too long + my ($last_full) = grep /^Last full backup date: /, `duply $profile status`; + my $full = ParseDate($last_full) lt ParseDate("5 days ago"); + + # user can override and force incremental if time or bandwidth is + # lacking + $full = prompt_Yn("Run full duply backup? (requires time & bandwidth)") + if $full; + + system "duply $profile " . $full ? "full_purge" : "incr"; +} + sub do_sysmaint { } diff --git a/bin/sysmaint b/bin/sysmaint index 0122d36a..8a1ff3da 100755 --- a/bin/sysmaint +++ b/bin/sysmaint @@ -369,23 +369,10 @@ if ( defined $loc ) { # ---- update duplicity backups now that all syncing is done -# TODO offer to force a full backup if the user indicates they have -# the time and bandwidth; otherwise just let duply decide between full -# and incremental. This reduces the likelihood the full backup will -# happen when I'm on random coffee shop WiFi. -# -# Oh! How about turning off MAX_FULLBKP_AGE such that only sysmaint +# TODO How about turning off MAX_FULLBKP_AGE such that only sysmaint # performs a full backup? This eliminates the random coffee shop WiFi # problem. Document that we're using that strategy, for laptops only, # in the duplicity config file. -# -# Also, if doing this, can reduce the sleep in workstation-backup to -# just five minutes, since the backup should always be much faster. -# -# Parse output of duply status, conditionally include DateTime, offer -# to do a full backup only if it's been five days since the last? -# This is convenient if I need to run sysmaint more than once in a -# day. if ( $can_run_duply ) { $seq->add_should_succeed("duply $host-$user-home backup"); diff --git a/bin/workstation-duplicity b/bin/workstation-duplicity index 0656e0d5..fe092a85 100755 --- a/bin/workstation-duplicity +++ b/bin/workstation-duplicity @@ -34,7 +34,7 @@ if ! [ -t 1 ]; fi # don't try to backup immediately; we might not be online for long - sleep 600 + sleep 300 # confirm we're still online if offline; then @@ -44,8 +44,9 @@ if ! [ -t 1 ]; fi if [ -e "$FLAG_FILE" ]; then - # attempt an incremental backup - duply $DUPLY_PROFILE backup_purge --force + # attempt an incremental backup -- always incremental since we + # might be running from a cronjob on weak coffee shop WiFi + duply $DUPLY_PROFILE incr --force else # interpret lack of flag file to mean this host's OS has been # reinstalled. Do a full backup, as doing an incremental backup |