]> khamidou — GitHub mirrors - tinybackup.git/commitdiff
initial commit
authorkarim hamidou <khamidou@gmail.com>
Wed, 7 May 2014 15:04:51 +0000 (17:04 +0200)
committerkarim hamidou <khamidou@gmail.com>
Wed, 7 May 2014 15:04:51 +0000 (17:04 +0200)
fabfile.py [new file with mode: 0644]
tarsnap-backup.sh [new file with mode: 0755]

diff --git a/fabfile.py b/fabfile.py
new file mode 100644 (file)
index 0000000..1ce8bf2
--- /dev/null
@@ -0,0 +1,42 @@
+# fabfile for update and deploy
+# it's necessary to specify an host
+from fabric.api import *
+from fabric.contrib.project import rsync_project
+from fabric.contrib.files import upload_template
+
+PACKAGES = ('build-essential')
+TARSNAP_VERSION = '1.0.35'
+
+def setup_packages():
+    sudo("apt-get update")
+    for package in PACKAGES:
+        sudo('apt-get -y install %s' % package)
+
+def build_tarsnap():
+    #FIXME: validate keys
+    #local("curl 'https://www.tarsnap.com/download/tarsnap-autoconf-1.0.35.tgz' -o /tmp/tarsnap.tgz")
+    #local("curl 'https://www.tarsnap.com/download/tarsnap-sigs-1.0.35.asc' -o /tmp/")
+    #local("curl 'https://www.tarsnap.com/tarsnap-signing-key-2013.asc' -o /tmp/")
+    #local("gpg --decrypt /tmp/tarsnap-sigs-1.0.35.asc")
+    with lcd('/tmp'):
+        local("tar xzvf tarsnap.tgz")
+        with lcd('/tmp/tarsnap-autoconf-%s' % TARSNAP_VERSION):
+            local('./configure && make')
+            local('sudo make install')
+
+def register_machine():
+    email = raw_input("Tarsnap email: ").rstrip()
+    mname = raw_input("Machine name: ").rstrip()
+    local("sudo tarsnap-keygen --keyfile /root/tarsnap.key --user %s --machine %s" % (email, mname))
+    print "Saved Tarsnap key to /root/tarsnap.key. MAKE A COPY SOMEWHERE SAFE."
+
+def setup_cron_job():
+    local("sudo cp tarsnap-backup.sh /etc/cron.daily") 
+    print "Saved CRON script to /etc/cron.daily. Edit /etc/cron.daily/tarsnap-backup.sh if you want to add directories to the backup.")
+
+def setup():
+    setup_packages()
+    build_tarsnap()
+    raw_input("If it's not done, go create an account at http://tarsnap.com, and add some balance to your account.")
+    register_machine()
+    setup_cron_job()
diff --git a/tarsnap-backup.sh b/tarsnap-backup.sh
new file mode 100755 (executable)
index 0000000..a5dc31d
--- /dev/null
@@ -0,0 +1,2 @@
+#! /bin/bash
+tarsnap cf Documents-`date +%F` --cachedir /root/.tarsnap_cache --keyfile /root/tarsnap.key ~/Documents