Back Up and Synchronize Files between a Desktop and Laptop on SLED 10
Backing up files, keeping files in sync between Desktop and Laptop pc’s, and connecting to folders on other computers.
I have a Desktop pc and a Notebook pc, both of which run SLED 10. I use a USB hard disk as my backup and use RSYNC to do my backups.
I use a script file which I store in /.gnome2/nautilus scripts directory in my home directory, this allows me to backup with a right click on the desktop.
This is the file. I might add that all the switch explanations can be found by using the man rsync command at your terminal.
#!/bin/sh rsync -av --delete --exclude=Cache /home/peterm/Documents /home/peterm/.mozilla/firefox /media/disk/sled10 >/home/peterm/Documents/mylogs/backuplog.txt
Actually that is a cut down version, I back up a lot more directories, but in the interests of saving space here……..
Anyway, that all works very well. Now that I have got the 2 pc’s however I don’t want to be plugging in the usb drive from 1 pc to the other whenever I want to update files, so I used rsync again.
NOTE: I have exactly the same user name and directory structures in my Laptop and Desktop.
At first I scoured the man pages for rsync to get some clues how to use it over the network and with a bit of……. well alright then, a lot of trial and error I got it working between my Desktop and Laptop.
First, I decided I would use ssh as the transport method. Not really any particular reason other than it seemed simple.
I had to open the ssh port in the firewall. This is done through YAST, in the Security and users section, select Firewall then Allowed services. It’s just a simple matter of scrolling down to pick the service you wish to allow.
The next step was working out the syntax, I started by using this:
rsync -r -e ssh --delete /home/peterm/mylogs peterm@\192.168.0.2:/home/peterm/test
It was only later that I found out I could enter the hostname in YAST | Network services |Hostnames and then use the host name instead of the ip-address:
rsync -r -e ssh --delete /home/peterm/mylogs peterm@hp-laptop:/home/peterm/test
So now I can send my files to the laptop, very quickly as rsync uses a very smart algorithm and only send the changes.
If I want to be extra tricky, I can start a ssh session from the laptop to the desktop and then run the rsync on the desktop, but from the laptop.
There is no reason why you cannot reverse the action and sync from laptop to desktop, but you should keep track of which way you synced! I make it write a log file.
The following command is run from my Laptop, it will connect my Laptop to the Desktop with a SSH session, then I run the rsync command on the Desktop to send all the changes to my Laptop and write to a log file.
ssh sled10 rsync -r -e ssh --delete --progress /home/peterm/Documents peterm@\hp-laptop:/home/peterm/ >/home/peterm/Documents/mylogs/sync-to-laptop.txt exit
But wait, there’s more!
You can place an icon on your desktop that will open a nautilus window and connect to a folder on your other pc by using the Connect to a remote server facility.
- Right click your panel, select Add to panel, then select Connect to a server, add it to your panel.
- Now click on Connect to a remote server.
- A window pops up with several configuration options.
- Select your Service type, I stay with SSH seeing as I have got my Firewall opened up for it already.
- Put in the IP address, or name of the other computer you want to connect to.
- You do not need to add anything into the port field.
- Select the folder you want to access, then the user name and add a name for your connection.
Thats it, you’re ready to connect.
Click on the connect button.
An icon will be placed on your desktop, click on it. If you have not connected like this before you will be presented with a question of do you want to proceed, select log in anyway.
Enter the password for the user you are connecting to and you’re in.
You can save all that for future connections to this folder as well.
You have a Nautilus window open of the folder on the other computer.
It’s all pretty cool 🙂
This had all been done on SLED10 with all updates applied.