From e6a9280e42d1a9e2bb703368cfb64179b0774b30 Mon Sep 17 00:00:00 2001 From: Jude N Date: Tue, 17 Feb 2015 14:22:00 -0500 Subject: [PATCH] New duply-with-powernap post / some old uncommitted changes --- content/hints/duply-with-powernap.rst | 54 +++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 content/hints/duply-with-powernap.rst diff --git a/content/hints/duply-with-powernap.rst b/content/hints/duply-with-powernap.rst new file mode 100644 index 0000000..b934cfa --- /dev/null +++ b/content/hints/duply-with-powernap.rst @@ -0,0 +1,54 @@ +Duply with a powernapping system +################################# + +:date: 2015-02-17 +:tags: hints,ubuntu,duply,powernap +:category: hints +:author: Jude N + +I've started `backing up one of my systems to S3`_. The instructions from the Phusion blog worked almost perfectly, except my TARGET line was:: + + TARGET='s3+http:// + +Also on the AWS side, I set up a lifecycle rule to archive the backups to Glacier after 7 days. + +I did run into some issues getting the backups to work together with `powernap`_, which is configured to put the system to sleep after a few minutes of keyboard inactivity. + +Powernap was causing a problem on two fronts. First, the system was going to sleep mid-backup since full backups take longer than the powernap inactivity timeout. The other problem was the backup was scheduled for the middle of the night when the system would normally already be asleep. + +To get around the mid-backup sleep issue, I made a /usr/local/bin/duply-nightly script which shuts down powernap before calling duply and restarted it afterwards. + +In order to get around the system-already-asleep issue, I'm using `an RTC wakeup`_, in /usr/local/bin/duply-nightly to set the system to wake a few minutes before the cron job kicks off (but not early enough for powernap to put the system to bed again...) + +The final /usr/local/bin/duply-nightly script is below + +.. code-block:: bash + + #!/bin/sh +x + + /usr/bin/logger "Running nightly backup from $0 + + # Disable powernap during the backup + service powernap stop + + /usr/bin/duply nightly backup + + # Wakeup the system at 3:00am tomorrow + echo 0 > /sys/class/rtc/rtc0/wakealarm + echo `date '+%s' -d '3am next day'` > /sys/class/rtc/rtc0/wakealarm + + # Enable powernap again. + service powernap start + +The cron job that kicks on /usr/local/bin/duply-nightly is below + +.. code-block:: bash + + SHELL=/bin/sh + PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin + + 5 3 * * * root env HOME= /usr/local/bin/duply-nightly > /var/log/duply-nightly.log + +.. _backing up one of my systems to S3: http://blog.phusion.nl/2013/11/11/duplicity-s3-easy-cheap-encrypted-automated-full-disk-backups-for-your-servers/ +.. _powernap: https://launchpad.net/powernap +.. _an RTC wakeup: http://www.linux.com/learn/docs/672849-wake-up-linux-with-an-rtc-alarm-clock -- 2.39.2