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.
I'm a Linux administrator in my company, and I'm working in with a server in a different location from the production server of my office. I've a task of pulling daily database backups (mysql) from the production server to my local server.
The original backups are of course in the production server. Backups are done daily in that server, using automysql backup script. So for example, for the database named myob, the backups are as follows :
If today were Thursday, and the backup time set in cron was 12.30 p.m. , then the backup would be named as below :
myob_2009-12-03_12h30m.Thursday.sql.gz
If it were Friday, then the backup name would be :
myob_2009-12-04_12h30m.Friday.sql.gz
and so it goes.
So how do I pull the database backups daily from Monday to Friday to my local server. Is there a way to use scp command in a script and then put that script in cron as a daily cron job to pull the database backups?
Pls help. Tqs.
Last edited by anaigini45; 12-03-2009 at 11:01 PM.
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197
Rep:
I would think it would be easier to combine the transfer with the script that does the backup, on the remote machine. That simplifies things, because it generates the dump file, gzips it, and then scp's it to your server. As chrism01 says, use authorized keys (whichever way you go). Detailed howto here http://sial.org/howto/openssh/publickey-auth/.
rsync would handle that - only copy stuff that's different between
the two machines. Alternatively you could make a shell-script
that creates a matching time-stamp for you name and build the
name on the fly before scp-ing.
You need to tell us a bit more about what you want.
If its an after-the-fact he can check situation, just create an entry in a DB and use a website to pull up the records; assuming a non-tech end-user.
You could just email him the result, it's easy enough.
Is there a way to actually make an excel sheet track the downloading and uploading of each of the backups automatically?
Maybe I did not use the word automatically? Is it possible to make rsync or sth work automatically daily (to pull/download the backups from the production server and then push/upload into the client's server) ?
What I mean is I do not have to interfere. I just set things up and it is supposed to work the way I want it.
A good example would be using the automysqlbackup script. If the script is located in cron, then the backups are done automatically without my interference. At the specified time everyday, the backups are made.
Is it possible to do the same with pulling and pushing the backups? AND ALSO making excel track these at the same time?
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197
Rep:
rsync can push or pull. Do it by hand to see it work. Then put it in cron. It can be automated in the same way as automysqlbackup or anything else.
If you really want a spreadsheet, a spreadsheet will easily import a comma delimited or tab delimited file. Decide what fields you want and then append a record to the file each time your script runs. Have a spreadsheet with a macro that reads that file in. Then your client/boss/whoever can open the spreadsheet and it will automatically (with the macro) import and format the file. You'll have to play with that and figure it out. It will depend, of course, on your spreadsheet and platform of choice at that end.
Yep, a csv file import is simplest. That's why I was asking exactly what you want.
You can certainly build a script to do the file moving, then create/append to the csv.
Put the script in cron (after testing) and away you go.
NB: in cron the default env/path is minimal, so it's recommended to use full/absolute paths to all cmds & files mentioned in the script.
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197
Rep:
Take it one step at a time to figure out what's up. In post #7, you said it works. So, you had an rsync command that you executed by hand that worked. Presumably, that is what you put in your script. Is the script executable? Did you try just running it by hand? Are you sure there were changes on the remote server to copy when the script ran? The crontab entry looks alright, and, if you edited it using `crontab -e` it would have complained if there were format errors. Yours is set to execute at 6:45pm every day. If the cron job generates error output, it should also generate an email to the user the cron job is running as. If you aren't getting email, running it by hand would show you any errors.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.