about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-08-27 19:04:04 +0530
committerAndinus <andinus@nand.sh>2020-08-27 19:04:04 +0530
commitfdc444fae9ea570f59110f09db599d19ed254f0d (patch)
treed2fb58bedd2fa77dc8528df64e02fcca7cdc9b2d
parentecf1581cfde9e4872d28a77baac7b3ceafcacf7a (diff)
downloadleo-fdc444fae9ea570f59110f09db599d19ed254f0d.tar.gz
Change mentions of "archive" to "backup"
This is a backup program now. By archive I think of something else,
like I archive web pages to save them offline. And by backup I think
of storing files safely somewhere so that we can restore it later.

Doesn't matter.
-rw-r--r--README20
-rwxr-xr-xleo.pl26
2 files changed, 25 insertions, 21 deletions
diff --git a/README b/README
index cb1f1fd..a0ee021 100644
--- a/README
+++ b/README
@@ -18,8 +18,8 @@ Table of Contents
 3 History
 
 
-Leo is my archival program. It creates tar(1) files from a pre-defined
-list. It can encrypt/sign files with gpg2(1).
+Leo is a simple backup program. It creates tar(1) files from a
+pre-defined list. It can encrypt/sign files with gpg2(1).
 
 • Web-site: [https://andinus.nand.sh/leo]
 • Source: [https://git.tilde.institute/andinus/leo]
@@ -29,8 +29,8 @@ list. It can encrypt/sign files with gpg2(1).
 1 Documentation
 ═══════════════
 
-  I use this to quickly archive some of my files & copy them to another
-  computer as a backup.
+  I use this to quickly backup some of my files. It works on profiles,
+  profiles are simple lists of files which get backed up.
 
 
 1.1 Profile
@@ -38,9 +38,9 @@ list. It can encrypt/sign files with gpg2(1).
 
   Profile is a simple hash table which contains the list of profiles.
   The profiles are mapped to a list of file paths relative to `$HOME'
-  which are to be archived.
+  which are to be backed up.
 
-  Complex profiles are hard coded & simple ones are generated. Complex
+  Complex profiles are hard-coded & simple ones are generated. Complex
   profiles include profiles that have multiple files or are a mix or
   files & directories. Simple profiles are profiles with just single
   directory.
@@ -68,7 +68,7 @@ list. It can encrypt/sign files with gpg2(1).
   `encrypt_sign' handles `gpg2' related functions. It passes `--yes' by
   default.
 
-  *Note*: `gpg2' might compress the archives depending on your config.
+  *Note*: `gpg2' might compress the backups depending on your config.
    Default is to enable compression, if you don't want this then add `-z
    0' to `@options'. `-z' specifies the compression level & 0 means no
    compression.
@@ -81,7 +81,7 @@ list. It can encrypt/sign files with gpg2(1).
 1.2.2 delete
 ╌╌╌╌╌╌╌╌╌╌╌╌
 
-  Removes the archive file after running gpg2(1). This means that either
+  Removes the tar file after running gpg2(1). This means that either
   `encrypt' or `sign' option must be passed.
 
 
@@ -123,3 +123,7 @@ list. It can encrypt/sign files with gpg2(1).
   that function. So, it's not a meta-program anymore. I was thinking of
   creating something that does all the things for me but that'll be too
   complex.
+
+  Later on the same day I removed dispatch table & switched to using
+  simple hash of lists to store backup paths mapped to profiles. And
+  also changed the word "archive" to "backup" everywhere.
diff --git a/leo.pl b/leo.pl
index c208169..52e8cfd 100755
--- a/leo.pl
+++ b/leo.pl
@@ -20,9 +20,9 @@ $options{delete} = $ENV{LEO_DELETE};
 
 my $gpg_fingerprint = "D9AE4AEEE1F1B3598E81D9DFB67D55D482A799FD";
 my $ymd = ymd(); # YYYY-MM-DD.
-my $archive_dir = "/tmp/archive/$ymd";
+my $backup_dir = "/tmp/backup/$ymd";
 
-path($archive_dir)->mkpath; # Create archive directory.
+path($backup_dir)->mkpath; # Create backup directory.
 my $prof;
 
 my %profile = (
@@ -56,7 +56,7 @@ foreach my $arg ( @ARGV ) {
             if $prof eq "journal" and $options{encrypt};
 
         # Deref the array here because we want flattened list.
-        archive("$archive_dir/${arg}.tar", $profile{$arg}->@*);
+        backup("$backup_dir/${arg}.tar", $profile{$arg}->@*);
 
         $options{encrypt} = $tmp if $prof eq "journal";
     } else {
@@ -65,27 +65,27 @@ foreach my $arg ( @ARGV ) {
 }
 
 # User must pass $tar_file first.
-sub archive {
+sub backup {
     my $tar_file = shift @_;
-    my @archive_paths = @_;
+    my @backup_paths = @_;
 
-    say "Archive: $tar_file";
+    say "Backup: $tar_file";
     warn "[WARN] $tar_file exists, might overwrite.\n" if -e $tar_file;
     print "\n";
     # All paths should be relative to $ENV{HOME}.
     tar_create($tar_file, "-C", $ENV{HOME}, @_);
 
     $? # tar returns 1 on errors.
-        ? die "Archive creation failed :: $?\n"
-        # Print absolute paths for all archived files/directories.
-        : say path($_)->absolute($ENV{HOME}), " archived."
-        foreach @archive_paths;
+        ? die "Backup creation failed :: $?\n"
+        # Print absolute paths for all backup files/directories.
+        : say path($_)->absolute($ENV{HOME}), " backed up."
+        foreach @backup_paths;
 
     print "\n" and tar_list($tar_file) if $options{verbose};
     encrypt_sign($tar_file) if $options{encrypt} or $options{sign};
 }
 
-# Encrypt, Sign archives.
+# Encrypt, Sign backups.
 sub encrypt_sign() {
     my $file = shift @_;
     my @options = ();
@@ -112,7 +112,7 @@ sub encrypt_sign() {
 }
 
 sub HelpMessage {
-    say qq{Archive files to $archive_dir.
+    say qq{Backup files to $backup_dir.
 
 Profile:};
     foreach my $prof (sort keys %profile) {
@@ -128,7 +128,7 @@ Options:
     --sign
         Sign files with $gpg_fingerprint
     --delete
-        Delete the archive after running gpg2
+        Delete the tar file after running gpg2
     --verbose
     --help};
 }