So this is my backup solution, it consists of two scripts:
1.) I replaced the standard
/usr/lib/hal/scripts/hal-system-power-suspend
script with the following code to ensure that every time the computer goes to sleep (e.g. close the lid) it will wake up for the backup:
#!/bin/sh
#Determine when to wake up computer
waketime="01:30"
waketimesec="0"
if [ `date --date=$waketime +%s` -gt `date +%s` ]
then
echo today
waketimesec=`date --date=$waketime +%s`
else
echo tomorrow
waketimesec=`date --date="tomorrow $waketime" +%s`
fi
#Determine switch sleep modus to choose
state=`cat /proc/acpi/ac_adapter/AC0/state | grep on-line`
if [ "$state" = '' ]
then
echo Computer on battery mode
sudo /usr/sbin/pm-suspend
else
echo Computer on AC mode
sudo rtcwake -m mem -t $waketimesec
state=`cat /proc/acpi/ac_adapter/AC0/state | grep on-line`
if [ "$state" = '' ]
then
sudo /usr/sbin/pm-suspend
fi
fi
Notice that no backups are made if the AC-Adapter is unplug and the computer is running on battery.
2.) The second script does the actual backup and is triggered by cron a few minutes after the wake-up. It wakes up the remote destination computer, mounts a smbfs share, performs a differential backup using backintime and shuts down the remote computer, then puts the local pc back to sleep:
#!/bin/bash
echo Wake up destination computer and sleep...
wakeonlan <mac_address>
date
echo ..sleep for 90s #the time your computer needs to boot and start smb
sleep 90
echo Mounting share..
sudo smbmount //<ip_address>/backup_folder /home/<user>/local_folder/ -o username=<user>,password=<pass>,file_mode=0777,dir_mode=0777,uid=1000,user
echo ..share mounted!
echo Starting backup!
backintime --backup > backintime.log
echo Backup finished, giving it time to settle..
sleep 10
echo Unmounting share..
sudo smbumount /home/<user>/local_folder/
sleep 5
echo Shutdown remote computer...
ssh '<user>@<ip_address>' "sudo shutdown -h now"
echo Going back to sleep..
/usr/lib/hal/scripts/hal-system-power-suspend
For every sudo command use visudo to grant superuser rights. Use publickey authorization to avoid password-prompts on the ssh command.
Now you have fresh backups every night with minimal power-consumption. Hope this helps someone.