How to regularly backup Windows XP to Ubuntu, using rsync
How to regularly backup Windows XP to Ubuntu, using rsync
Back in September I revived my Mini-ITX box to serve as a backup server. I set up BackupPC, ran it once, it seemed to work, and then ignored it for weeks. When I checked back, it hadn’t run successfully since. Ugh, I want backups to just work!
A few nights ago I decided to try again, this time dropping the constraint of not installing software on my laptop. Turns out I already had the building block I needed: rsync, installed in the form of Cygwin.
I began with these Rsync for Windows instructions, and everything went smoothly until the very end—rsync on Windows wasn’t connecting to rsync on Ubuntu. My gut told me rsync’s port 873 isn’t open on Ubuntu, but I had no idea how to open ports anymore. Luckily I found How to start rsync daemon at boot in the Ubuntu forums which told me exactly what I needed to know.
Partly as an aide to my memory, and partly to help anyone out there who might be struggling with the same project (unless everyone except me is already backing up their computers) I decided to summarize the process without all the false starts and dead ends it took me to figure it all out. For more information, the rsync man page is useful, as well as the results in Google for windows rsync.
Set up rsync server on Ubuntu
- Run
sudo apt-get install rsync
(it’s probably already installed) - Create a file named rsyncd.conf in /etc
-
sudo nano /etc/rsyncd.conf
- Add the following to rsyncd.conf, replacing all instances of
username
with your Ubuntu username:[usernamebackup]
path = /home/username/backup
comment = Backup
uid = username
gid = username
read only = false
auth users = username
secrets file = /etc/rsyncd.secrets -
sudo chmod 644 /etc/rsyncd.conf
-
- Create a file named rsyncd.secrets in /etc
-
sudo nano /etc/rsyncd.secrets
- Add the following to rsyncd.secrets, replacing
username
with your username andpassword
with a password of your choosing:username:password
-
sudo chmod 600 /etc/rsyncd.secrets
-
- Open rsync port by editing /etc/default/rsync and setting
RSYNC_ENABLE=true
- Restart rsync
sudo /etc/init.d/rsync restart
Set up rsync client on Windows
- Install Cygwin, making sure Editors > nano and Net > rsync are selected
- Add
C:\cygwin\bin;
to the Windows PATH statement- Right-click on My Computer and select Properties
- Switch to the Advanced tab and click the Environment Variables button at the bottom
- Find the “Path” or “PATH” variable in the System variables list at the bottom and click Edit
- Add
C:\cygwin\bin;
to the beginning of the list
- Create secret file to store password in Cygwin
- Start Cygwin Bash Shell
- Create secret file in the filesystem root and enter only the password in rsyncd.secrets above, with no spaces or line breaks
nano /secret
-
chmod 600 /secret
-
chown Administrator:SYSTEM /secret
- Create bat file to run rsync
- Open Notepad and enter the following command, replacing User Name with your Windows User Name directory, username with your Ubuntu username, and ipaddress with the IP address of your Ubuntu server (e.g. 192.168.0.100):
C:\cygwin\bin\rsync.exe -qrtz --password-file=c:\cygwin\secret --delete "/cygdrive/c/Documents and Settings/User Name" username@ipaddress::usernamebackup
As you may have guessed, the
"/cygdrive/c/Documents and Settings/User Name"
command line option designates where to start backing up from. As currently configured, this will backup your Windows home directory (Desktop, My Documents, etc). If you want to backup your whole hard drive, change that option to"/cygdrive/c"
. - Save the file as C:\rsync.bat
- Open Notepad and enter the following command, replacing User Name with your Windows User Name directory, username with your Ubuntu username, and ipaddress with the IP address of your Ubuntu server (e.g. 192.168.0.100):
Create scheduled task to run C:\rsync.bat once a day
- Create scheduled task
- Goto Start > Programs > Accessories > System Tools > Scheduled Tasks
- From the File menu, select New > Scheduled Task
- Name this task “rsync backup”
- Right-click on the task and select properties
- Enter
C:\rsync.bat
in the Run field - Switch to the Schedule tab and select the time you want the backup to run every day and click Ok
- Test the scheduled task
- Create a folder called C:\data and put a few photo files in it
- Edit C:\rsync.bat and change
"/cygdrive/c/Documents and Settings/User Name"
to"/cygdrive/c/data"
- Add the command
pause
on a new line at the bottom of C:\rsync.bat and save the file - Right-click on the “rsync backup” scheduled task and select “Run”—A command window should popup and with either errors or the list of files being transfered. If there are errors, troubleshoot them.
- Once the scheduled task and C:\rsync.bat appear to be working correctly, change
"/cygdrive/c/data"
back to"/cygdrive/c/Documents and Settings/User Name"
and remove thepause
command - Finally, edit the scheduled task properties and change “Run as:” to
NT AUTHORITY\SYSTEM
—this will ensure that the process runs in the background, without popping up a command prompt window
Run your first backup
Run C:\rsync.bat from the command line before going to bed. Backing up 35GB over a wireless-g connection took me over 8 hours. Subsequent backups take less than a minute. Behold the beauty of rsync.
2 comments:
Nice brief and this fill someone in on helped me alot in my college assignement. Thanks you on your information.
buy levitra online canada
buy
Post a Comment