Backup depending on bootups or connections to wifi network

Asked by wwjd

Hi Terry,

this is more a suggestion than a question:

The scheduler in deja-dup offers some options to chose from: every day, every week and so on.
I would suggest to offer an additional type:

Backup every bootup, every second boot-up.
Or: Backup at every third connection to your local wifi-network.

Background 1:
Many avarage users do not use their notebook everyday.
There might be two weeks of heavy usage - than a daily backup would be senseful.
But there might be a week of lazyness - where there is just nothing to backup.

Background 2:
In these days it becoms quite popular to have a local NAS at home, where your can play media files from and -- where you can backup to.
Backing up is only possible, when you have access to your local NAS, mostly through your wifi-router.

deja-dup could count the connections to the local wifi-network and start the backup after a specific numberof connections.

I wrote a small script to illustrate this:

#!/bin/bash

USERNAME="<put your username here>"
ESSID_ATHOME="<put the id of your wifi network here>"
MAX_CONNECTIONS=5

COUNTER=/home/$USERNAME/.counter
if [ -e $COUNTER ]; then x=$(<$COUNTER); else x=0; fi

case "$2" in
        up)
                if (nm-tool | grep -q $ESSID_ATHOME); then
   echo $((x+1))>$COUNTER
   if [ $x -gt $MAX_CONNECTIONS ]; then
    sudo -H -u $USERNAME "deja-dup --backup"
    $(grep -z ^DISPLAY= "/proc/$(pgrep gnome-session)/environ") notify-send "Deja-Dup" "Backup started"
    echo $((x=0))>$COUNTER
   fi
         fi
                ;;

        *)
                echo $"Usage: $0 {up|down|pre-up|post-down}"
                exit 1
esac

exit $?

This script should go into /etc/NetworkManager/dispatcher.d/

The critical part is the line
sudo -H -u $USERNAME "deja-dup --backup"

deja-dup seems to start in root context anyway. (Any suggestions for that?)

Thank your for listening!

wwjd

Question information

Language:
English Edit question
Status:
Solved
For:
Déjà Dup Edit question
Assignee:
No assignee Edit question
Solved by:
Michael Terry
Solved:
Last query:
Last reply:
Revision history for this message
Best Michael Terry (mterry) said :
#1

But since backups are usually incremental, why would it really matter? If a user's usage is light, the incremental will be that much smaller. (For case #1)

For case #2, seems like the current behavior isn't bad. If enough time has passed and the NAS is visible, we'll backup. The question is, would we error out if NAS isn't available or not. I suspect we currently error out. So in your scenario, it might be better not to. Not sure how we could detect this scenario vs an SSH server that you would want to know about connection problems to.

I'm not sure about the sudo question. :-/

Revision history for this message
wwjd (wwjd) said :
#2

Thank you!