The Following 5 Users Say Thank You to magick777 For This Useful Post: | ||
![]() |
2011-09-07
, 17:35
|
Posts: 167 |
Thanked: 204 times |
Joined on Jul 2010
|
#2
|
#!/bin/sh # Script to launch an automated backupmenu run # Requires: backupmenu # Target directory where to find our backups LOCALDIR="/media/mmc1/systemBackups"; # Number of individual archives to keep; if you backup rootfs + optfs then set this to DOUBLE the number of backup sets you want # THIS WILL DELETE BACKUPS OUT OF THE DIRECTORY ABOVE. UNDERSTAND THAT BEFORE YOU USE IT. SET KEEP=999 to effectively disable. KEEP=4 # Begin script error() { msg=$@ dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:"$msg" uint32:0 string:"OK"; exit 1; } # Check if we are on a GSM call and abort silently if so TEST=`dbus-send --system --type=method_call --print-reply --dest=com.nokia.csd.Call /com/nokia/csd/call/1 com.nokia.csd.Call.Instance.GetStatus | grep -o "uint32 0"`; if [ -z "$TEST" ]; then exit 1; fi; # First check that we are on charge and abort silently if we are not TEST=`hal-device bme | grep -o "maemo.charger.connection_status = 'connected'"` if [ -z "$TEST" ]; then exit 1; fi; # Check that the target directory is readable, error out if not if [ ! -r "$LOCALDIR" ]; then error "AutoBackupMenu was launched but could not find $LOCALDIR. Is your MMC card mounted?" fi # Remove all but the latest $KEEP backups, setting KEEP=4 and backing up nightly will give you 3 days' worth. ls -1 $LOCALDIR > /tmp/.backups cat /tmp/.backups | tail -n $KEEP > /tmp/.keep comm -3 /tmp/.backups /tmp/.keep > /tmp/.lose cd $LOCALDIR cat /tmp/.lose | xargs rm -f # Now check whether we have sufficient space on the microSD card if [ `df|grep mmc1|awk {'print $4'}` -lt 2097152 ]; then error "AutoBackupMenu was launched, but was aborted as there is less than 2GB free on your microSD card." exit 1; fi # Maybe insert here a check for larger OptFS, will 2GB free be sufficient? # A few more sanity checks. We don't want to set /autobackupmenu and reboot unless and until we believe # it stands a good chance of working. if [ ! -x "/usr/share/backupmenu/AutoBackupMenu.item" ]; then error "AutoBackupMenu could not find /usr/share/backupmenu/AutoBackupMenu.item and assumes that it is not correctly installed. Aborting." fi if [ -z `grep -o AutoBackupMenu /usr/share/backupmenu/BackupMenuLauncher.item` ]; then error "AutoBackupMenu could not find itself mentioned in /usr/share/backupmenu/BackupMenuLauncher.item and assumes that it is not correctly installed. Aborting." fi if [ -z `grep -o /autobackupmenu /sbin/preinit` ]; then error "AutoBackupMenu could not find itself mentioned in /sbin/preinit and assumes that it is not correctly installed. Aborting." fi # OK, good enough for us. Let's do it. touch /autobackupmenu reboot
maemo:~# ls -alh /media/mmc1/systemBackups/If you want to make this work whether or not the keyboard is open, which I do, you can make another edit to /sbin/preinit to run bootmenu.sh any time there is an /autobackupmenu file on disk whether or not the keyboard is open. This is potentially dangerous in that if nothing deletes that file during the startup process, you've got a reboot loop into bootmenu that you can't fix just by closing the keyboard - so I'm leaving this as an exercise to the reader.
drwxrwxrwx 2 user root 8.0K Sep 11 04:31 .
drwxrwxrwx 6 user root 8.0K Jan 1 1970 ..
-rw-r--r-- 1 user root 459.9M Sep 9 04:33 20110909-0330-optfs.tar
-rw-r--r-- 1 user root 260.6M Sep 9 04:31 20110909-0330-rootfs.tar
-rw-r--r-- 1 user root 480.5M Sep 11 04:33 20110911-0330-optfs.tar
-rw-r--r-- 1 user root 261.0M Sep 11 04:31 20110911-0330-rootfs.tar
The Following User Says Thank You to magick777 For This Useful Post: | ||
I've been looking for a way to automate proper backups on the N900, i.e. taking proper local backups of the RootFS and OptFS exactly as BM does, but making it happen nightly without user intervention. My design goals include working with BackupMenu, so that I can rely on it for the restore side of things. So, I've come up with a bunch of hacks and kludges that allow me to automate nightly backups using BackupMenu. It's still very much a work in progress, but I'd like to share it here for further comment and insight. Credit and thanks is due to RobbieThe1st for BackupMenu itself, without which I'd have nothing to automate.
So, as a starting point, we bastardise a copy of the core of BM to operate as if we had pressed b to backup, t for both, s twice for put both to SD card, then q to reboot once we're finished. You'll want to copy /usr/share/backupmenu/BackupMenu.item to AutoBackupMenu.item and bastardise it to suit your needs. See attached. Then, we modify the end of /usr/share/backupmenu/BackupMenu.item as follows:
And that's as far as I've got. Still need to clean up the old backups and devise some sanity checks to run before I automate the business of running this from cron. Comments and constructive criticisms welcomed; deploy at your own risk.
Last edited by magick777; 2011-09-06 at 03:09.