Script/Batch command to initiate file transfer between Windows and Ubuntu

1

So I've setup a backup system for my notebook. Using Rsync, I am able to backup specific folders to my Ubuntu Home Server by executing a batch file.

My question is about the possibility of automating the sync process. The catch is, I want my laptop to begin the syncing process if and only if:

  1. I connect to a specific Network through a Wireless Access Point. (I access my home network through WiFi when I'm on my notebook. I want to let the backup process commence strictly only upon connecting to this one home network.)

  2. The Ubuntu Home Server is online. (Since the backup is automated it would be great if the backup would only be allowed to commence if and only if the Ubuntu Home Server has been uniquely identified - perhaps through its MAC?)

Not really that urgent, but I would be happy to hear from the experts here.

techtechmo

Posted 2009-10-08T12:34:18.233

Reputation: 314

Answers

1

Netprofiles can help you with the first part.

Features

  • Save your network settings as profiles.
  • Automatically activate wireless profiles when specified wireless connections are detected. (XP only)
  • Change IP Address, Subnet Mask, Default Gateway, Primary and Secondary DNS Servers, WINS Server, and DHCP settings with the click of a button.
  • Specifiy different mapped drives for each profile.
  • Change your default printer based on which profile you're currently using.
  • Automatically change your profile via program shortcuts created with Net Profiles.
  • Change the default homepage for Internet Explorer, Firefox, and Opera.
  • Proxy settings for Internet Explorer, Firefox, and Opera.
  • Run a user-defined list of programs when a profile is activated.
  • Maintain seperate desktop wallper for each profile.
  • Change screen resolutions and color quality when profiles are activated.
  • Can be easily translated into other languages using the enclosed XML language file.

I'd recommend using something other than batch for the second part, as it would be easier to control logic. Something like Perl's Net::Ping could help you.

John T

Posted 2009-10-08T12:34:18.233

Reputation: 149 037

Initially looking at Net::Ping was a bit intimidating, but thanks for the link. I'll definitely check it out. :) – techtechmo – 2009-10-09T00:13:37.013

Don't limit yourself to Perl. It's a great language, but it can sometimes appear cryptic and intimidating to newcomers depending on how it is presented. There are ping implementations everywhere, some excellent examples are showcased in this stackoverflow question: http://stackoverflow.com/questions/316866/ping-a-site-in-python

– John T – 2009-10-09T04:32:16.350

1

You could turn the problem on its head by having the Ubuntu server periodically ping for the Windows computer. If it finds it, it initiates a backup over Samba or something. You could configure this using BackupPC.

Edit: I'll elaborate on how BackupPC works. In your case, you'll be running BackupPC on your Ubuntu home server. BackupPC runs as a daemon, and periodically it will try to connect to your Windows computer via Samba. If it can establish a connection, it will copy all the folders that you configured it to back up from the Windows machine into its backup directory (and then it will do some space-saving tricks, which you mostly won't need to worry about). Then it will close the connection and wait until the next period to do it again.

The point is, once you've set this up, all you have to do is connect to your home network on a regular basis (which, presumably, is something you already do), and BackupPC will handle the scheduling of backups for you. The only thing you need to do on the Windows machine is to grant read-only file-sharing access to the Ubuntu server.

Ryan C. Thompson

Posted 2009-10-08T12:34:18.233

Reputation: 10 085

Hi Ryan, would it be possible to get your backup script using backup pc? I haven't gotten around to trying this solution because I got bogged down by work, but now that I've gotten some free time I could try out your suggestion. I would be ever grateful for any assistance. :) – techtechmo – 2010-01-28T09:43:54.497

It's not my solution. The manual on the BackupPC website has quite complete documentation, if you can take the time to find what you're looking for. I mostly just followed the setup guide. – Ryan C. Thompson – 2010-01-28T22:19:17.773

This looks interesting, I'll try to read the documentation, to see how a Windows to ubuntu backup may be configured. Thanks! – techtechmo – 2009-10-09T00:12:32.350

I have this exact sort of setup configured for Linux to Linux backups, but I haven't tried it with Windows. It should work, though. BackupPC supports Samba. – Ryan C. Thompson – 2009-10-09T02:44:51.870