From 16112ec453264af340d66a0f625c4914a192ab98 Mon Sep 17 00:00:00 2001 From: Andinus Date: Thu, 27 Aug 2020 11:35:53 +0530 Subject: Add ssh to archive list, add date in tar file names Date was added in `yyyy-mm-dd' format because it'll be easier to manage these archives later. `ssh' was added to archive list, it archives `$ENV{HOME}/.ssh' directory. --- leo.pl | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'leo.pl') diff --git a/leo.pl b/leo.pl index fbcf243..cc7047b 100755 --- a/leo.pl +++ b/leo.pl @@ -72,16 +72,32 @@ sub tar_list { run3 ["/bin/tar", "tvf", @_]; } # Creating tars of files. sub archive { + my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = + localtime(time); + + $year += 1900; # $year contains the number of years since 1900. + + # $mon the month in the range 0..11 , with 0 indicating January + # and 11 indicating December. + my @months = qw( 01 02 03 04 05 06 07 08 09 10 11 12 ); + my $month = $months[$mon]; + + my $ymd = "$year-$month-$mday"; + my %archive_dispatch = ( "documents" => sub { - tar_create("/tmp/archive/documents.tar", + tar_create("/tmp/archive/documents_$ymd.tar", "-C", "$ENV{HOME}/documents", "."); }, "journal" => sub { - tar_create("/tmp/archive/journal.tar", + tar_create("/tmp/archive/journal_$ymd.tar", "-C", "$ENV{HOME}/documents", "andinus.org.gpg", "archive.org.gpg"); }, + "ssh" => sub { + tar_create("/tmp/archive/ssh_$ymd.tar", + "-C", "$ENV{HOME}/.ssh", "."); + }, ); shift @ARGV; @@ -103,6 +119,8 @@ Usage: Archive $ENV{HOME}/documents journal Archive $ENV{HOME}/documents/andinus.org.gpg, - $ENV{HOME}/documents/archive.org.gpg}; + $ENV{HOME}/documents/archive.org.gpg + ssh + Archive $ENV{HOME}/.ssh}; } } -- cgit 1.4.1-2-gfad0