From ef8644868ea0d8877223bfc523b33fd5e4c55345 Mon Sep 17 00:00:00 2001 From: Brad Clawsie Date: Sun, 14 Nov 2021 16:36:48 -0600 Subject: tarsnap --- tarsnap/daily_tarsnap.pl | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tarsnap/daily_tarsnap.pl (limited to 'tarsnap/daily_tarsnap.pl') diff --git a/tarsnap/daily_tarsnap.pl b/tarsnap/daily_tarsnap.pl new file mode 100644 index 0000000..a327c6d --- /dev/null +++ b/tarsnap/daily_tarsnap.pl @@ -0,0 +1,36 @@ +#!/usr/bin/env perl +use v5.32; +use strict; +use DateTime; + +my $dt = DateTime->now(); +$dt->set_time_zone('America/Chicago'); +my $prefix = 'b7j0cdebian_'; +my $prefix_yyyymmdd = $prefix . $dt->ymd(''); +my $prefix_reserve_yyyymmdd = $prefix . $dt->subtract('days'=>1)->ymd(''); +say "today:\t\t" . $prefix_yyyymmdd; +say "yesterday:\t" . $prefix_reserve_yyyymmdd; +my $tarsnap = 'tarsnap --cachedir /root/tarsnap-cache --keyfile /root/tarsnap.key'; +my $list_archives = `$tarsnap --list-archives`; +my $backup_paths = '/home /var/www'; +my $excludes = ''; +chomp($list_archives); +my @archives = split(/\n/,$list_archives); +my $make_yyyymmdd = 1; +my @delete_these = (); +for my $archive (@archives) { + say "list:\t\t" . $archive; + if ($archive eq $prefix_yyyymmdd) { + $make_yyyymmdd = 0; + } +} +my $tarsnap_cmd = ''; +if (1 == $make_yyyymmdd) { + say "make for today"; + my $yyyymmdd_cmd = $tarsnap . ' -c -f ' . $prefix_yyyymmdd . ' ' . $backup_paths . ' ' . $excludes; + say $yyyymmdd_cmd; + $tarsnap_cmd = $yyyymmdd_cmd . ';'; +} +say $tarsnap_cmd; +system($tarsnap_cmd) if ($tarsnap_cmd ne ''); +1; -- cgit v1.2.3