Recently Written · git

encrypted-home-backups

Automated home backups, onto an encrypted partition

git clone https://github.com/equwal/encrypted-home-backups

Log | Files | Refs


commit 4a30dc785db0cc0680975a0ae746ee3ac89b885c
Spenser Truex <spensertruexonline@gmail.com>
2019-04-02 14:58:32 -0700

v1.0

 backup | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
diff --git a/backup b/backup
new file mode 100755
index 0000000..cd2cb89
--- /dev/null
+++ b/backup
@@ -0,0 +1,27 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+my $uuid = $ARGV[0];
+my $keyfile = $ARGV[1];
+print "Press any key when the device is plugged in.\n";
+getc();
+# Put auto-dev-detect code here
+my $last_half;
+my $blkid = `blkid`;
+print "$blkid\n$uuid\n$keyfile";
+if($blkid =~ /(.*)$uuid.*/) {
+    print $1;
+    my $tmp = $1;
+    $tmp =~ m#/dev/(.*?):#;
+    $last_half = $1;
+} else {
+    die "Could not get a device ID from that UUID."
+}
+my $mount = "/mnt/dev/$last_half";
+my $mapper = "/dev/mapper/$last_half";
+`cryptsetup --key-file $keyfile luksOpen /dev/$last_half $last_half`;
+`mkdir -p $mount`;
+`mount /dev/mapper/$last_half $mount`;
+# Do a home-only backup
+my $bname = `date`;
+`tar -cjf '$mount/backup-$bname.tar.bz2' /home/jose`;