Wednesday, September 15, 2010

backup up a windows desktop to an ubuntu server

Prepare the server. Install Ubuntu Server 10.04.1, and choose the OPENSSH option for server type.

On Windows client:
- install cwRsync
- create your working folder for rSync, e.g. c:\sshstuff
- copy the cwrsync.cmd batch template from cwrsync's install folder to the working folder
- set the windows system environment PATH variable to include the cwRsync folders
- get the user name, e.g. lavezarez

On the Ubuntu server:
Create a user id to user for ssh rsync operations.
- modify the /etc/adduser.conf file and change -> DIR_MODE=0750
- create the user ID
sudo adduser backuper
and follow the prompts.

Below are repetitive steps for each Windows machine to backup:

Back on the windows client:
- Generate ssh public & private keys
ssh-keygen -q -b 1024 -t rsa -f cwrsync -N '' 
Assign a unique file name for the key. It shouldn't be cwrsync all the time.
- via winscp
Create the destination folder for the Windows machine's files.
Copy the pub key to the ubuntu server (via winscp or other means), at /home/user location. Multiple desktops to backup can have a SINGLE Ubuntu user login, having multiple pub keys.

back on the ubuntu server:
- logged on with the windows user's name,

these steps untested, from cwRsync FAQ --
mkdir -p .ssh
cat cwrsync.pub > .ssh/authorized_keys
ln -s .ssh/authorized_keys .ssh/authorized_keys2
chmod 755 home/backuper home/backuper/.ssh
chmod 644 home/backuper/.ssh/authorized_keys
chown backuper.ssh .ssh/authorized_keys

You only have to do all these steps the first time. The only step you repeat for each Windows machine is the cat command.

For 2nd and other Windows machine, the pub key must be copied to Ubuntu and appended to its authorized_keys2, much like:
->copy the foo.pub file via winscp to Ubuntu server.
->ssh ubuntu server, login as the backuper user
then type:
cat foo.pub >>~/.ssh/authorized_keys2

This tip taken from this site.

It may also be easier for you to set the permission octals and ownership using winscp.

back on the windows:
Create backup folder in ubuntu via winscp
then try the rsync NOW!

Typical rSync options: --progress --delete -avhe "ssh -i /cygdrive/c/sshbackup/mykey"
where sshbackup is the folder where the private ssh key is stored in Windows
and mykey being the actual private ssh key file.

References:
cwRync reference
Ubuntu server openssh reference
Ubuntu server adding users reference

No comments:

Post a Comment