My smart backup script :O

I was used to have a rsync call in my crontab to perform backup from my laptop to my desktop. My idea was to backup my laptop everyday even if I wasn’t at home, so before the time that the rsync ran I had to make sure that I was connected to my home network via OpenVPN and that my desktop was on.

If the day was calm, no problem, but when I was busy at work that meant no backup for that day.

I decided to code my own script to solve this problem.

for the dialogs, I had to install ‘xdialog’

Also, I’m calling another script called ‘vpn’ that I made with expect, it’s used to connect to my OpenVPN server with the passphrase I specify with a parameter.

if $argcsend_user “usage: \n”
send_user “$argv0 password \n”
send_user “”
exit
}

spawn sudo /usr/sbin/openvpn –config /etc/openvpn/openvpn.conf –daemon
expect “Enter Private Key Password:”
send “[lindex $argv 0]\r”
interact

In my router I made an script called ‘wakeup’ that only runs:

Hope you can use it for something, if not, you have a good example of how to use Xdialog, expect and some other things.