Automated backup
Since August 18, my software development work has been picking up its pace and I have checked in more works more often, at least five times on single productive day. Ever since, I have been manually backing up Subversion directory using tar. My project server is fornax.
Fornax is a 6-year old PC running Ubuntu. It wasn’t working properly due to the cooling fan in its power supply unit. Until about two weeks ago, I replaced the old fan. I am not very confident about the replacement because it is a third party part and the replacement isn’t as good as expected, but it works. I have to shut it down every night before going to bed.
So, the last thing before I go to bed is to backup the svn directory and then shutdown the server. I am quite fed up with this extra manual works. Last night, before going to bed, I decided to automate this process. And I did it this morning.
I wrote a simple bash shell script to do the backup. I cron it so that the process will start automatically at 2300 hours and then shutdown.
#!/bin/bash
BACKUPFILE=/tmp/backups/svn-$(date +%Y%m%d).tar.gz
rm /tmp/backups/svn-*.gz
tar -cj /svn > $BACKUPFILE
for COMPUTER in host1 host2
do
scp $BACKUPFILE user@$COMPUTER:Desktop/
done
/sbin/shutdown -h +5
UPDATE (05/10/2009): I setup a password-less ssh login so that no password is required for scp (secured copy). Now, after the backup, the backup file will be copied automatically to two other computers for safe keeping.
Backup your Mac with AppleScript
All programmers are lazy. They want to automate tasks as much as they can. Because of this uniquely great habit, they have developed countless of useful software.
Ok. I am lazy. I have been using rsync to sync folders I am working on between my Macs. I have been using command line scripts in Terminal for almost two years and finally I have gotten lazy over the task.
The thing is, I need to execute the scripts in Terminal every time I want to synch my folders. Of course, I could simply use cron to automate the tasks at specific time but I ran the risk to cause havoc between the folders on different Macs. It is best not to cron the task.
So, I learned up AppleScript and after a ten-minute hack, I wrote a nice AppleScripts to do the job. It is quick and dirty.
set debug to false
with timeout of (30 * 60) seconds
tell application "Terminal"
set Window_Title to "Sync Documents"
set Rsync_Cmd to "rsync -acrtv --delete
/Users/username/Documents/
username@xxx:Documents"
set output_doc to do shell script Rsync_Cmd
choose from list paragraphs of output_doc with prompt
"Result:" with title Window_Title with empty
selection allowed
end tell
end timeout
Copy the script to ~/Library/Scripts/Applications/Finder and save it as “sync documents.scpt”. Then launch Script Editor to edit username to your login name and xxx to your Mac IP address or computer name. This script will sync your Documents folder under your user home directory. To execute this AppleScript, at Finder, click on the script icon on the menu bar and select the script to launch.
rsync uses ssh. If you have not setup a password-less ssh login, you will need ssh-askpass in /usr/libexec. Unfortunately, it does not ship with Mac OS X. You can get it at Joe Mocker’s weblog.
Is your connection secured?
Internet has become a common tool to connect your mobile computer back to the computers in your office while you are on the go. When you are out there negotiating business with your client, you need to extract a file from your computer in your office but you are hundred or maybe thousands miles away, how can you retrieve your file?
The answer is by using FTP or File Transfer Protocol. You can make connection from your mobile computer to your office computer via an Internet connection. It is very convenient to use. But there is a security concern. All communications between your mobile and office computers can be read like an open book by anyone lurking in the Internet. You need a secured way to transfer your sensitive business data.
Pragma Systems SFTP client provides you a secured FTP connection by encrypting all data before they leave your computers. You can be rest assured of the confidentiality of your data during transmission. Don’t leave your office without it. You never know who is watching.


Listen to my podcast