![]() |
Need help with rSync
Hello!
I need help with making an rSync script. I want the script to backup my homefolder, \Macintosh HD\Users\Me to my NAS disk \\192.168.65.100\share. Im going for rSync since it only transmit the changes in a file on bit level. Also, as this disk is on the network, I will probably need something to make the login happen. The username and passoword is simply admin / admin. Im planning to insert the script into the daily script. That way it wil run automatically every nigth, and Ill also have an easy way of running it manually. If someone could show me a script that would do this I would be grateful. Thanks! |
'man rsync' would give you the options you want.
The command would be: Quote:
Quote:
This is the Applescript (saved say in /Users/me/mount as an application): Code:
tell application "Finder"Code:
#!/bin/sh |
Thanks for your reply!
What would be the difference between \Users\Me\ and \Users\Me ? |
The difference between \Users\Me\ and \Me
is that the directory \Me\ will be copied, so that you will now have a NAS\Share\Me\(files) on your NAS. Where if you use \Me you will get NAS\Share\(files). Hope that makes sense. |
Also, if you toss the -u switch in there, it will only update the rsync when files are modified or data is added, so it will basically synchronize your data from one share to the next. There are some caveats though, like for example there are known issues with it preserving time and date stamps on data.
Also, when writing a script it is best practice to actually type in the full paths of commands Code:
#!/bin/bash |
Don't you need the -E switch, so rsync includes resource forks?
|
Quote:
|
I mentioned it because I had a problem transferring some files that had resource forks. I didn't get to confirm that -E would work (it does locally) over a network, because I was transferring to a Panther system, and apparently -E wasn't included in Panther's rsync!
|
Thanks for your help!
Ill see if I get the time to test a scripts tomorrow :) The \Me\ or \Me clarification made perfect sense :) Thanks! |
So the full code would be:
/sbin/mount afp://admin:admin@192.168.0.80/nas /usr/bin/ rsync -r -o -u ~/ /Volumes/nas/ Where should this shellscript be stored? Will I be able to start it manually and via the daily routine in a simple way? Thanks again :) |
rsync backup to SFTP server...
Not sure if anyone can help.....
I have an important database file that i need to backup offsite to an FTP server (or ideally by SCP/SSH/SFTP) Can somebody help with a shell script that i can use to do this. I just need to replace the file remotely with file from server on a daily basis. I will use launchd to get the script to run.... |
You could use:
scp /path/to/filename.ext username@address:/path/to/filename.ext |
Savage-
just mount the volume before you run the script, you can mount FTP via the finder. I think it should work, test it out. |
hi there tlarkin......
Indeed this should be easy to sort out but have once again been running into trouble. The key thing is this server is not maintained on a daily basis, I look at it once a week....so really need something pretty bullet proof to implement. There are onsite daily backups which are handled by retrospect to hard disks, a once a week rsync back up to an offsite drive(manually done by an advanced user) and now with the implementation of a new FM CRM/Project management system it is imperative to get the databases offsite daily. I need two FM databases backed up to a remote FTP space on a daily basis. Ideally without the use of flakey finder FTP mount which tends to fail. any ideas of how i can do this.....??? |
does it have to be FTP? Can you rsync it to a NFS share or something else?
|
in short no it is a remote webserver....
I can ssh,ftp,sftp to server |
you could connect the mount point over ssh, then use rsync.
|
I notice that Cyberduck is Applescript aware and it has a sync capability...
|
I will give it a go.
thx |
Quote:
|
Hello again!
Thanks for all your help. Scripting is not something Im very good at, so Im sorry about asking the same questions over and over... Hope someone can clarify a few things for me: 1. Where do I create the shellscript (textedit or terminal)? 2. Where should I save it 3. If its called "backup.sh" or "backup.command", how will I start it from the terminal? I need to be able to do this both from the prompt and within the daily routine 4. Should it be saved as *.sh or *.command? 5. Below I have tried to make the script as I have understood your feedback. Does it seem correct? #!/bin/bash #this script will run rsync on home directory to a set NAS share /sbin/mount afp://admin:admin@192.168.0.107/sonos/ /usr/bin/rsync -r -o -u -e /Volumes/Machintosh HD/Users/Me/ /Volumes/192.168.0.107/sonos/ Thanks again for your help :) |
The script looks fine, you can create it in any text editor. I prefer text wrangler (google it, free download) but you can use Apple's text edit. Make sure that you you set text edit's preferences to always run as plain text. If you make a script as rich text it will not work.
Save the file as .sh. Now, you can set up a cron job, or apple script to make it executable in the finder. The cron job will run the script at set time and date, and repeat as need be. The apple script would make it have the ability to run with in the finder not having to use the terminal. |
Thanks for your help!
So /path/to/backup.sh added to the /etc/daily would do the trick as a schedule. And an AppleScript to make it excetutable manually? |
check out these links they explain it in more detail
http://www.macosxhints.com/article.p...01020700163714 on this link scroll down to the crontab part http://www.macdevcenter.com/pub/a/ma...minal_one.html |
Thanks again :)
|
Hello again!
I cant make the script work in applescript... tell application "Finder" mount volume "afp://admin:admin@192.168.0.107/sonos/" end tell Works great and the disk connects. However, Im not able to make the script run: do shell script /Users/Me/Desktop/Backup.sh What would the syntax for this part be? Can both functions be in the same script? Thanks again for your help :) |
Try:
do shell script "/Users/Me/Desktop/Backup.sh" |
That seems to work. However, now I get an permissions denied message..
It does not help to put sudo in fornt of /usr/bin/rsync |
Do you have permission to execute the script: /Users/Me/Desktop/Backup.sh
Post what you see if you type this in a terminal window: ls -la ~/desktop/Backup.sh |
if he created it, he should have ownership, which by default gives you rwx permissions.
Are you logged in as administrator? You may want to delete your bash profile under your user account, or better yet test it under a new user account and see if it still denies permission. |
Quote:
|
Really? In my experience everything I create script wise is owned by my user account, even in text edit. I typically save things in my home directory in a folder called 'scripts' then once it is fully tested I duplicate it and toss it on the network or the local client machines.
|
Yes, it's owned by your user account, but TextEdit doesn't make its files executable. That would make the file rw– instead of rwx, so while it could be read or written to, it couldn't be executed as a script.
A simple: chmod 7?? filepath should take care if it, assuming that's the problem. |
Oh, the difference is I always execute scripts manually, with the sh command, before I change ownership and permissions (to make it owned by root or whatever).
So, that is where I was getting confused, but a simple chmod +x /path/to/script will make it executable. |
The preferred method:
Quote:
|
well the difference is, +x makes it executable across the board, where the numbers 751 are for owner, group, everyone. So, you have more control. Each method has its use.
|
| All times are GMT -5. The time now is 05:44 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.