about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-08-27 11:35:53 +0530
committerAndinus <andinus@nand.sh>2020-08-27 11:35:53 +0530
commit16112ec453264af340d66a0f625c4914a192ab98 (patch)
tree14627d67a67ad5a9641572e59db9fd61eee7578f
parent9e478c175e2f178320f4eae851e3f4feccb7145e (diff)
downloadleo-16112ec453264af340d66a0f625c4914a192ab98.tar.gz
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.
-rwxr-xr-xleo.pl24
1 files changed, 21 insertions, 3 deletions
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};
     }
 }