]> apps.delaporte.us Git - dotfiles.git/commitdiff
Add remote backup tool
authorEdward Delaporte <edward@delaporte.us>
Tue, 21 Jul 2026 22:08:57 +0000 (17:08 -0500)
committerEdward Delaporte <edward@delaporte.us>
Tue, 21 Jul 2026 22:08:57 +0000 (17:08 -0500)
invoke/backup/tasks.py [new file with mode: 0644]

diff --git a/invoke/backup/tasks.py b/invoke/backup/tasks.py
new file mode 100644 (file)
index 0000000..8f91c46
--- /dev/null
@@ -0,0 +1,27 @@
+'''
+Typical use:
+
+    invoke backup (host) ~/backup
+    invoke show-backup (host)
+'''
+import os
+from invoke import task
+
+
+# TODAY = dt.now().strftime('%Y.%m.%d')
+HOME=os.path.expanduser('~')
+BACKUP_TO=f'{HOME}/backup'
+
+@task
+def backup(c, host, path):
+    os.path
+    TMP_TAR=f'/tmp/backup.{host}.tar'
+    c.run(f'ssh {host} -C tar cf {TMP_TAR} {path}')
+    c.run(f'scp {host}:{TMP_TAR} {BACKUP_TO}')
+
+@task
+def show_backup(c, host):
+    c.run(f'ls {BACKUP_TO} | grep {host}')
+    c.run(f'tar tvf {BACKUP_TO}/backup.{host}.tar | tail')
+    c.run(f'tar tvf {BACKUP_TO}/backup.{host}.tar | wc')
+