Eggmeng Posted March 15, 2013 Share Posted March 15, 2013 Hi, I have cron jobs set up on my server to run two shell scripts for backing up a wordpress site. The script that backs up the files is working but the one that is supposed to back up the db is not. I will pay someone who know shell scripting language, for the time it takes to look at the code and fix it. Please send me a pm if interested and available and if you have a bonafide company. Thanks, Link to comment Share on other sites More sharing options...
Crushdepth Posted March 15, 2013 Share Posted March 15, 2013 Why not set a cron job to dump the database to a file as well? (Preferably outside your web root). It'd be a one-liner. You could also have a look at rsnapshot, which is simple, free and gives you snapshots/versioning of your file system and/or database. Link to comment Share on other sites More sharing options...
Eggmeng Posted March 15, 2013 Author Share Posted March 15, 2013 Why not set a cron job to dump the database to a file as well? I did. That's the script that's not working. I need someone to fix it so it does. Link to comment Share on other sites More sharing options...
JSixpack Posted March 15, 2013 Share Posted March 15, 2013 Have you looked for a good WP extension to handle this for you? Link to comment Share on other sites More sharing options...
Eggmeng Posted March 15, 2013 Author Share Posted March 15, 2013 You mean a plug in? Yes, I'm using one now that was free, and looking at another one with better features that I will have to pay for. In the meantime I'd like to get both cron jobs working. I feel sure the code fix would take 5 minutes for someone who knows what they are doing. Plugins are great but they constantly have to be updated and sometimes they break. Link to comment Share on other sites More sharing options...
Guest Posted March 15, 2013 Share Posted March 15, 2013 I do scripting (but not coding). Do you get any error messages? Would you be able to post the script here so we'll be able to take a peak? Check: Crontab, which user is running the script (and that it has privileges to access the database), script execute privileges / ownership. After this you can try to rung the script on command line with the correct user.. this might bring out some error messages. -- So first check that the crontab entry is in order crontab -l -u username_which_is_runnign_the_script #This is probably the database user Then check that the script permissions are ok. ls -l /path/to/the/script.sh It's possible that the script simply lacks execute privileges. You can add some chmod 755 /path/to/the/script.sh And then try to run in manually /path/to/the/script.sh Link to comment Share on other sites More sharing options...
Eggmeng Posted March 15, 2013 Author Share Posted March 15, 2013 Okay, here is the file back up script, which works fine, where public html is the root directory . #!/bin/sh backup_files="/home/eggmeng/public_html" dest="/home/eggmeng/public_html/shell-backups" day=$(date +%A) host=$(hostname -s) archive_file="$host-$day.tgz" tar czf $dest/$archive_file $backup_files And here is the db backup script which doesn't work. #!/bin/bash PATH=/usr/sbin:/sbin:/bin:/usr/bin user="[db_name_goes_here]" pass="[db-password_goes_here]" host="localhost" sub="$(date +"%Y-%m-%d")" dest="/home/eggmeng/public_html/shell-backups" mdb="$dest/db/$sub" if [ ! -d $mdb ] then mkdir -p $mdb >/dev/null 2>&1 && echo "Directory $mdb created." || echo "Error: Failed to create $mdb directory." else echo "Error: $mdb directory exits!" fi now="$(date +"%Y-%m-%d_%H-%M-%S")" file="" dbs="$(mysql -u $user -h $host -p$pass -Bse 'show databases')" for db in $dbs do file="$mdb/$db.$now.sql.gz" mysqldump -u $user -h $host -p$pass --complete-insert $db | gzip -9 > $file echo "Backup $file.....DONE" done find $dest/db/ -maxdepth 1 -type d -mtime +6 -exec echo "Removing Directory => {}" \; -exec rm -rf "{}" \; Link to comment Share on other sites More sharing options...
Guest Posted March 16, 2013 Share Posted March 16, 2013 For the first, you need to replace the ">" with ">" and "&" with "&" on your script. The second last line does not matter, just an beauty thing, but these lines will make the script fail: mkdir -p $mdb >/dev/null 2>&1 && echo "Directory $mdb created." || echo "Error: Failed to create $mdb directory." --> mkdir -p $mdb > /dev/null 2>&1 && echo "Directory $mdb created." || echo "Error: Failed to create $mdb directory." mysqldump -u $user -h $host -p$pass --complete-insert $db | gzip -9 > $file --> mysqldump -u $user -h $host -p$pass --complete-insert $db | gzip -9 > $file After modifications try to run it manually and report the possible error messages. Link to comment Share on other sites More sharing options...
Eggmeng Posted March 16, 2013 Author Share Posted March 16, 2013 Thanks ENC. I made the mods, replaced the script and I'm getting this email notification and the same result as before, wherein a folder named with today's date is created inside another folder named DB. But the folder is empty. Looks like the script is being denied access to the db, doesn't it? + PATH=/usr/sbin:/sbin:/bin:/usr/bin + user='[actual_db_name]' + pass='[actual_db_password]' + host=localhost ++ date +%Y-%m-%d + sub=2013-03-16 + dest=/home/eggmeng/public_html/shell-backups + mdb=/home/eggmeng/public_html/shell-backups/db/2013-03-16 + '[' '!' -d /home/eggmeng/public_html/shell-backups/db/2013-03-16 ']' + echo 'Error: /home/eggmeng/public_html/shell-backups/db/2013-03-16 directory exits!' Error: /home/eggmeng/public_html/shell-backups/db/2013-03-16 directory exits! ++ date +%Y-%m-%d_%H-%M-%S + now=2013-03-16_05-20-01 + file= ++ mysql -u 1 -h localhost '-p[actual_db_password]' -Bse 'show databases' ERROR 1045 (28000): Access denied for user '1'@'localhost' (using password: YES) + dbs= + find /home/eggmeng/public_html/shell-backups/db/ -maxdepth 1 -type d -mtime +6 -exec echo 'Removing Directory => {}' ';'-exec rm -rf '{}' ';' Link to comment Share on other sites More sharing options...
Guest Posted March 16, 2013 Share Posted March 16, 2013 That looks like it. Your username is '1' ? Could you double check that one as well as the password. Then try on the command line if you can connect to the database mysql -u user_name_here -pthe_password_for_the_username Link to comment Share on other sites More sharing options...
Eggmeng Posted March 16, 2013 Author Share Posted March 16, 2013 Both the user name and the pw match exactly what I have in the config file. I copied and pasted them from there. So I don't understand why this error message is returning "1". Link to comment Share on other sites More sharing options...
Eggmeng Posted March 16, 2013 Author Share Posted March 16, 2013 Here is more or less what the user name looks like in the script: user="[eggmeng_alphanumericstring1]" Link to comment Share on other sites More sharing options...
Guest Posted March 16, 2013 Share Posted March 16, 2013 Ah. Remove the "[" "]" marks from both this one as well as from the password --> user="eggmeng_alphanumericstring1" Link to comment Share on other sites More sharing options...
Eggmeng Posted March 16, 2013 Author Share Posted March 16, 2013 You are a gentleman and a scholar sir. I drink to success, and to your health! Link to comment Share on other sites More sharing options...
Guest Posted March 16, 2013 Share Posted March 16, 2013 Great to hear it works! Btw. Last night I drunk for the health. Today I'm feeling that the effects were only temporary. Memory corrupted, system not in good health, but the core was not dumped! Link to comment Share on other sites More sharing options...
Eggmeng Posted March 16, 2013 Author Share Posted March 16, 2013 Yes, avoiding fatal errors is the main thing. And thank you. Link to comment Share on other sites More sharing options...
dharmabm Posted March 20, 2013 Share Posted March 20, 2013 I love seeing these kinds of conversations here! Link to comment Share on other sites More sharing options...
reesarick Posted May 14, 2013 Share Posted May 14, 2013 Oilinki, Your answers for Eggmeng a few months ago were so helpful for me, too! Thank you! I am still getting a couple errors... would you be willing to take a look and see if you find any problems? THANK YOU!!!!! File backup ERROR: tar: AM.tgz: Cannot stat: No such file or directory tar: Removing leading `/' from member names tar: /home/content/m/i/l/milwaukiepre/html/cron_backups/p3nlh229-Tue-05-14-13-12\:05\:02: file changed as we read it File backup SCRIPT: #!/bin/sh backup_files="/home/content/m/i/l/milwaukiepre/html/" dest="/home/content/m/i/l/milwaukiepre/html/cron_backups/" day=$(date +%a-%m-%d-%y-%r) host=$(hostname -s) archive_file="$host-$day.tgz" tar czf $dest/$archive_file $backup_files Database backup ERROR: (not really an error, but I'd rather not get an email every day) Directory /home/content/m/i/l/milwaukiepre/html/cron_backups//db/2013-05-14 created. Database backup SCRIPT: #!/bin/bash PATH=/usr/sbin:/sbin:/bin:/usr/bin user="milwaukiepre" pass="Fun2learn" host="milwaukiepre.db.6018926.hostedresource.com" sub="$(date +"%Y-%m-%d")" dest="$HOME/html/cron_backups/" mdb="$dest/db/$sub" if [ ! -d $mdb ] then mkdir -p $mdb >/dev/null 2>&1 && echo "Directory $mdb created." || echo "Error: Failed to create $mdb directory." else echo "Error: $mdb directory exits!" fi now="$(date +"%Y-%m-%d_%H-%M-%S")" file="" dbs="$(mysql -u $user -h $host -p$pass -Bse 'show databases')" for db in $dbs do file="$mdb/$db.$now.sql.gz" mysqldump -u $user -h $host -p$pass --complete-insert $db | gzip -9 > $file echo "Backup $file.....DONE" done find $dest/db/ -maxdepth 1 -type d -mtime +6 -exec echo "Removing Directory => {}" \; -exec rm -rf "{}" \; Ah. Remove the "[" "]" marks from both this one as well as from the password --> user="eggmeng_alphanumericstring1" Link to comment Share on other sites More sharing options...
edwardrake Posted June 25, 2013 Share Posted June 25, 2013 (edited) "I do scripting (but not coding)". == oilinki Puppy 5.5 ... having a hard time getting dual monitors running. Any ideas? Ed Edited June 25, 2013 by edwardrake Link to comment Share on other sites More sharing options...
ttwitt Posted July 6, 2013 Share Posted July 6, 2013 "I do scripting (but not coding)". == oilinki Puppy 5.5 ... having a hard time getting dual monitors running. Any ideas? Ed ask at puppy forum theres vastly more people familiar there. #puppylinux chat sometimes has action for quick questions. just one way to get there http://webchat.freenode.net/?channels=puppylinux Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now