Linux.com

Author Message
Joined: Jun 30, 2008
Posts: 3
Other Topics
Posted Jun 30, 2008 at 8:47:53 PM
Subject: easy script for backing up a directory then copying it acros

Hi all,

This is my first post in these forums. If I posted in the wrong place feel free to scold me.

I was wondering if someone would help me out with a very basic script. I need to create a backup of a directory on a Mac running OS X 10.5 using tar, then copy it across a Windows network to a Mac server running OS X 10.4.

The tar command I was trying to use goes like this:

tar -cfz filename.tar.gz /Users/userdirectory

I'm not sure about the copying accross the network part. Also I was going to use cron to have it run every day at 3:30 am.

The Mac server is named AweMacSvr1 and the domain name is bob-andy.com as an example.

Thanks!!

Just a guy working for the man.

Back to top Profile Email Website
Khabi
Joined Apr 21, 2008
Posts: 104

Other Topics
Posted: Jul 01, 2008 1:49:02 AM
Subject: easy script for backing up a directory then copying it acros

windows shares are normally called smb or samba shares in the *nix world. What you want to do is create your tar, mount the share, copy it over, then unmount the share.

I don't have a mac to test any of this out, but the basic is something like this:

Thats just the basics of it. You probably want to make tar output the file to a specific directory, and probably even delete the file when you're done transfering it.
Also, I would suggest putting the filename as a variable at the start of the script, even the user and server name as well. That way its easy to modify down the line if you need to.

If none of that makes sense, feel free to ask about it. This should get you started though, and making you modify it should help you learn what you're doing. :)

I also highly suggest reading: http://tldp.org/LDP/abs/html/ to learn basic bash scripting.
[Modified by: Khabi on July 01, 2008 01:49 AM]

Back to top Profile Email Website
Severcool
Joined Jun 30, 2008
Posts: 3

Other Topics
Posted: Jul 02, 2008 4:05:35 PM
Subject: easy script for backing up a directory then copying it acros

Thank you so much!! This will get me going in the right direction. I will let you know if I need anymore help. :)

Just a guy working for the man.

Back to top Profile Email Website
Severcool
Joined Jun 30, 2008
Posts: 3

Other Topics
Posted: Jul 02, 2008 4:43:17 PM
Subject: easy script for backing up a directory then copying it acros

OK so I'm not copying to a Windows server it's a Mac server. herefore I don't think this command will work: mount_smbfs -W

Just a guy working for the man.

Back to top Profile Email Website
Khabi
Joined Apr 21, 2008
Posts: 104

Other Topics
Posted: Jul 02, 2008 6:55:16 PM
Subject: easy script for backing up a directory then copying it acros

Ah, okay. You had said a "Windows network" so I just assumed you were doing windows filesharing with that Mac.

So the only problem is I don't have a mac of my own to test any of this, but generically (I think the mac has these apps) these should be good alternatvies. The syntax might change a little bit though.

Rsync: rsync filename.tar.gz user@host:/destination/directory
scp: scp filename.tar.gz user@host:/destination/directory

Both of these would require you to have a user on the remote machine, and ssh running on it as well. For simple 1 file transfers I would recommend going with the scp method. Rsync is more suited for keeping a directory on a remote machine in sync with one on a different machine.

There might be a better Mac specific way of doing this, but I'm not sure. :)

Back to top Profile Email Website
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya