LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-23-2006, 09:03 AM   #1
muskiediver
LQ Newbie
 
Registered: Mar 2006
Posts: 24

Rep: Reputation: 15
In plesk , I wish to have a backup cron job, ftp back up file to another ftp server?


I have this cron job (currently testing):

30 17 * * * mysqldump -h mydomainip -u myusername -mypassword --add-drop-table -n --databases mydatabasefile >"/var/www/vhosts/mydomain/database$(date +%g%m%d_%H%M).sql"

What I would like to so is ad a part that would allow me to have these files automatically ftp'd to another ftp server in another location? Any suggestions please?
 
Old 11-24-2006, 05:28 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
1. Move your backup command to a file, call the file "/etc/cron.daily/backup-sql-ftp.cron".
2. Change the crontab entry to "30 17 * * * /etc/cron.daily/backup-sql-ftp.cron".
2. Contents of the file "/etc/cron.daily/backup-sql-ftp.cron":
Code:
#!/bin/sh
FTP_USER='your_ftp_accountname'
FTP_PASS='your_ftp_password'
DUMP="/var/www/vhosts/mydomain/database$(date +%g%m%d_%H%M).sql"

mysqldump -h mydomainip -u myusername -mypassword --add-drop-table -n \
--databases mydatabasefile >"${DUMP}"; [ ! -s "${DUMP}" ] && exit 1

ftp ftp.so.me.ho.st <<EOC
user $FTP_USER
$FTP_PASS
cd /upload/dir
put $DUMP
quit
EOC
exit 0
3. Test by running "sh /etc/cron.daily/backup-sql-ftp.cron".

* I think this should have been tacked on to http://www.linuxquestions.org/questi...d.php?t=504224 since that's where this all started. Keeping your questions and posts about the same subject together makes it easier for others to follow instructions. If you agree ask the mods of this forum to merge these two threads.

Last edited by unSpawn; 11-24-2006 at 05:36 AM.
 
Old 11-25-2006, 06:41 AM   #3
muskiediver
LQ Newbie
 
Registered: Mar 2006
Posts: 24

Original Poster
Rep: Reputation: 15
Thank you.

Just so I am understanding your post. Where do I put my username and password (on the ftp part)?

This will be very cool if I can get it working.
 
Old 11-27-2006, 04:07 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
See the first two variables in the script, replace "your_ftp_accountname" and "your_ftp_password" with the actual login and pass.
 
Old 12-19-2006, 12:44 PM   #5
storpappa
LQ Newbie
 
Registered: Dec 2006
Distribution: Fedora Core 4
Posts: 15

Rep: Reputation: 0
I checked out the other thread...seems this thread is in the area of what I need to do

I need to backup all of the contents of /home
I need to backup of the mysql databases

But some of the scripts to make the transfer and storage easier make a tar of the contents. Disk space today can handle that, but as the sites grow, I see that being a tough fit. Guess I can deal with that when it happens later.

And I came across one script that fired of an email at the end of each backup. Wish I had bookmarked it.

I'll post what I finally dig up, but I need to run a cron job calling a ftp backup script. Just a matter of finding one with a few bells and whistles
 
Old 02-08-2009, 10:55 AM   #6
djingo
LQ Newbie
 
Registered: Feb 2009
Posts: 2

Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
1. Move your backup command to a file, call the file "/etc/cron.daily/backup-sql-ftp.cron".
2. Change the crontab entry to "30 17 * * * /etc/cron.daily/backup-sql-ftp.cron".
2. Contents of the file "/etc/cron.daily/backup-sql-ftp.cron":
Code:
#!/bin/sh
FTP_USER='your_ftp_accountname'
FTP_PASS='your_ftp_password'
DUMP="/var/www/vhosts/mydomain/database$(date +%g%m%d_%H%M).sql"

mysqldump -h mydomainip -u myusername -mypassword --add-drop-table -n \
--databases mydatabasefile >"${DUMP}"; [ ! -s "${DUMP}" ] && exit 1

ftp ftp.so.me.ho.st <<EOC
user $FTP_USER
$FTP_PASS
cd /upload/dir
put $DUMP
quit
EOC
exit 0
3. Test by running "sh /etc/cron.daily/backup-sql-ftp.cron".

* I think this should have been tacked on to http://www.linuxquestions.org/questi...d.php?t=504224 since that's where this all started. Keeping your questions and posts about the same subject together makes it easier for others to follow instructions. If you agree ask the mods of this forum to merge these two threads.
I can create the file alright, but I am getting this error when trying to upload:

This security scheme is not implemented
This security scheme is not implemented
KERBEROS_V4 rejected as an authentication type
Password:Name (xxxx):
Login authentication failed

I can connect fine to ftp with a windows client.

Last edited by djingo; 02-26-2009 at 04:54 PM.
 
Old 07-16-2009, 03:13 AM   #7
Sureshan
LQ Newbie
 
Registered: Jul 2009
Posts: 4

Rep: Reputation: 0
Hi unSpawn

Thank you for the script.

I need the very same solution but I need the files that are being transferred not to be zipped. Can you advise as to how this could be done?

Many Thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
FTP cron job dad1001 Linux - Networking 1 07-22-2006 11:42 PM
FTP cron job seems to be sending OLD data dagalicous Linux - General 9 02-28-2006 02:50 AM
cron job to send file via ftp every 1 hour mcalizo Linux - Newbie 1 07-14-2004 03:50 AM
cron nightly backup to ftp server rkane Linux - Networking 2 03-04-2004 05:05 PM
Can I make a Cron job to synch/transfer a file from a folder to another FTP?... read efishta Linux - General 6 07-19-2003 10:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration