Register
It is currently Mon Sep 22, 2014 12:11 am

backup mysql db


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Mon Feb 17, 2014 7:58 pm   

Joined: Mon Feb 17, 2014 7:23 pm
Posts: 3
Hi
Im having trouble making this bash script work. If anyone can help me I would really appreciate it :)
Im on a Godaddy.com shared hosting Apache server running Linux.
I came up with this script after searching around the web:
(the sensible data has been masked)
The bash file is located at _db_backups/

Code:
#!/bin/bash
mysqldump -h host -u myuser -pPassword databasename > _db_backups/dbbackup.sql
gzip _db_backups/dbbackup.sql
mv dbbackup.sql.gz _db_backups/`date +mysql-BACKUP.sql-%y-%m-%d.gz`


so I configured a cron job to execute this script. And the resulting log is emailed to me and says:

Quote:
/var/chroot/home/content/01/3196601/html/_db_backups/backup.sh: line 1: ��!/bin/bash: No such file or directory
/var/chroot/home/content/01/3196601/html/_db_backups/backup.sh: line 2: _db_backups/dbbackup.sql: No such file or directory
gzip: _db_backups/dbbackup.sql: No such file or directory
mv: cannot stat `dbbackup.sql.gz': No such file or directory


So as you can see... everything is "No such file or directory"... Any ideas? :-/


Top
 Profile  
 PostPosted: Tue Feb 18, 2014 3:15 pm   

Joined: Mon Feb 17, 2014 7:23 pm
Posts: 3
Any one? :-/


Top
 Profile  
 PostPosted: Wed Feb 19, 2014 10:29 am   

Joined: Mon Feb 17, 2014 7:23 pm
Posts: 3
Never mind guys... I made a PHP file to execute the code and it worked fine.


Top
 Profile  
 PostPosted: Tue Mar 11, 2014 2:34 pm   

Joined: Tue Mar 11, 2014 1:59 pm
Posts: 1
Here is the working script as per your need.

#!/bin/bash
mysqldump -h host -u myuser -pPassword databasename | gzip -9 > `date +mysql-BACKUP.sql-%y-%m-%d.gz`


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP