Incremental compressed backups with perms and no root keys

I've looked for incremental backups that don't require root before, but I finally found it. Similar to rdiff-backup is a program called duplicity. It uses tar, gpg, and the rsync algorithm to store encrypted differential backups.

duplicity needs to be scripted a little bit to automate the backups. I came up with a script that will backup certain directories fully once a week and incrementally the rest of the week. I also disabled the encryption since the transfer method is secure (ssh in my case) and the end server is trusted. If you were using Amazon's S3 service or a public FTP share you might want to tweak this a bit.

/etc/cron.d/backup

32 3 * * 1-6 root /usr/local/sbin/backup.sh<br />32 3 * * 0 root /usr/local/sbin/backup.sh --full

/usr/local/sbin/backup.sh

1
#!/bin/bash<br /><br />v=&quot;-v0 --no-print-statistics&quot;<br />cmd=&quot;&quot;<br />duplicity=&quot;duplicity&quot;<br />opt=&quot;--no-encryption --volsize 100&quot;<br />dest=&quot;scp://taonas@thor.home.silfreed.net&quot;<br />maxage=&quot;1M&quot;<br />PASSPHRASE=<br />export PASSPHRASE<br /><br />for arg in $@; do<br />    [[ $arg == &quot;-v&quot; ]] &amp;&amp; v=&quot;-v4&quot;<br /> [[ $arg == &quot;--full&quot; ]] &amp;&amp; cmd=&quot;full&quot;<br />done<br /><br />dcmd_backup=&quot;$duplicity $cmd $opt $v&quot;<br />dcmd_age=&quot;$duplicity remove-older-than $maxage $opt $v --force&quot;<br /><br /># backups<br />$dcmd_backup /etc $dest/etc<br />$dcmd_backup /var/log $dest/var-log<br />$dcmd_backup /home \<br />     --exclude /home/silfreed/tmp \<br />    --exclude /home/silfreed/src/silfreednet/tmp \<br />    --exclude /home/silfreed/src/workspace \<br />  --exclude /home/silfreed/src/mozdev/workspace \<br />   --exclude /home/silfreed/.thunderbird/7g3nnt02.default/ImapMail \<br /> $dest/home<br /><br />mysqldump_dir=/tmp/mysqldump<br />mkdir $mysqldump_dir &amp;&amp; \<br /> chmod 700 $mysqldump_dir &amp;&amp; \<br />     mysqldump -u root  -A &gt; $mysqldump_dir/mysqldump.sql &amp;&amp; \<br />      $dcmd_backup $mysqldump_dir $dest/mysql<br />rm -rf $mysqldump_dir<br /><br /># age out paths<br />for path in /etc /var-log /home /mysql; do<br />     $dcmd_age $dest$path<br />done

links

social