Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hey all, I am Having trouble understanding why my backup script isn't doing its job. I need to copy the files from one directory (the share on my server where all the company files are stored) to another directory, where a backup drive is mounted. I wrote the following script using rsync. the when I run this script from the command line, it shows a list of all the files I need backedup, scrolling across the screen, but doesn't place these files in the backup directory. can anyone see what I did wrong? I also have 6 other scripts just like this one, one for every day of the week. these are supposed to be run by cron. Also is there a way to view what cron has run recently so I can tell if I set that up right?
here is my script:
#!/bin/bash
echo Backup of PSI Files in Progress, please wait...
rsync -avh --delete /PSIFiles /BackupofPSIFiles/autoBackup/monday
thanks for your help in advance,
Christopher
Last edited by cougar97536; 06-21-2009 at 01:40 PM.
rsync will fail if the parent directory isn't already created. There might be an rsync switch for that. But on mine it produces an error message if that happens. Does the directory /BackupofPSIFiles/autoBackup exist yet?
Otherwise I can't see any problem with your syntax.
Instead of having six scripts, you might just want to have one that uses the date command to output the day of the week. Those are backticks around the date command, not apostrophes.
The parent directory as well as all of the sub directories ie monday, tuesday, etc. are already created under autobackup I may look into streamlining it and only using one script, but first I need to get the copying working properly.
thanks for the help,
Christopher
I wrote the following script using rsync. the when I run this script from the command line, it shows a list of all the files I need backedup, scrolling across the screen, but doesn't place these files in the backup directory.
After the scrolling list, there should be output similar to this
Quote:
sent 3.60K bytes received 49 bytes 7.30K bytes/sec
total size is 1.72M speedup is 471.20
I have mangaged to get some more time to work on this... it seems that the rsync command does what I want, only if I type it into my shell, if it is in a script it just looks at all the directories... copying nothing.
any help fixing this thing would be appreciated, thanks for the help so far
Christopher King
If its in a script run by cron, be aware that the default env for cron is minimal, especially $PATH. In consequence, std rule is to use complete absolute paths to all cmds and files referenced.
Yes to what chrism01 wrote. If you change the first line of your script to #!/bin/bash -l (that's a letter ell) it will start bash in the same way as when you login.
Thanks for the help. So I have been running the backup command every night manually as follows:
rsync -avh --delete /PSIFiles /BackupofPSIFiles/autoBackup/monday
and it works great. Now if I run a shell script manually that contains the following:
#!/bin/bash -l
echo Backup of PSI Files in Progress, please wait...
rsync -avh --delete /PSIFiles /BackupofPSIFiles/autoBackup/monday
by typing ./test.sh
it seems to be working, scrolling through all the directories, and even gives me a finished message, but nothing changes in the backup directoty, any files that where changed since the last backup still aren't updated.
Till be nice when I figure this out, so I can stop worrying about my data being backed up. thanks again for the help.
Christopher King
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.