summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2018-06-01 20:59:41 +0000
committerIan C <ianc@noddybox.co.uk>2018-06-01 20:59:41 +0000
commitceb67522c8621b8a0fdf0de96739f01926b0ac57 (patch)
treef9a116d6012455838eb60126da1443c406a9b4cd
parentb426b0df4928fda9ebd84cc0e3eeb9f6116f9046 (diff)
Added linode backup script
-rwxr-xr-xlinode/backup.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/linode/backup.sh b/linode/backup.sh
new file mode 100755
index 0000000..3a5e2e1
--- /dev/null
+++ b/linode/backup.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+cd /
+
+DEST=data/backup
+SQL=tmp/dump-$$.sql
+PKGS=tmp/pkglist-$$
+
+SOURCE="home/ianc etc usr/local/etc usr/local/svn usr/local/svn-private $SQL $PKGS"
+
+BACKUP=$DEST/$(date +%Y%m%d-%H%S).tar.gz
+
+echo Dumping database
+mysqldump -u root --password=$(cat /usr/local/etc/mysqlpassword) --all-databases > $SQL
+
+echo Dump installed packages
+/usr/local/bin/listinstalledpkgs.sh > $PKGS
+
+echo Backing up to $BACKUP
+
+tar cfz $BACKUP $SOURCE
+
+rm -f $SQL
+
+cd $DEST
+echo Clearing old files
+find . -mtime +10 -print -exec rm {} \;