Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Cron Jobs Backup


Guest

Recommended Posts

Hello,

 

I'm add this contribution simple because I use it.

This script already on my computer for ages and I got it from another place. But since the original author not mentioned on the script, so I can not said who is he/she. :(

The credit should go to "John Doe" or "Jane Doe", not me.

 

The contribution uploaded at:

http://addons.oscommerce.com/info/7034

Edited by midave
Link to comment
Share on other sites

here's an improved script...maybe :) got some trouble on my server using your script. the base of this script i found on the internet (long time ago) too and did some modifcations.

 

#!/bin/bash
KEEP=31 # number of backups to keep
USER='user' # database user
PASS='pass' # database password
DB='db' # select the database to backup, or... 
#DB='--all-databases' # backup all databases (comment the line above)
BUPATH='/root/backup_etkatalog/db_backups' # path to this (!!) script

BACKUPS=`find $BUPATH -name $DB"-*.sql.gz" | wc -l | sed 's/\ //g'` 
while [ $BACKUPS -ge $KEEP ]
do
ls -tr1 $BUPATH/$DB-*.sql.gz | head -n 1 | xargs rm -f 
BACKUPS=`expr $BACKUPS - 1` 
done
DATE=`date +%Y%m%d%H%M%S`
rm -f $BUPATH/.$DB-${DATE}.sql.gz_TMP
/usr/bin/mysqldump $DB --opt -Q -u$USER -p$PASS | gzip -c -9 > $BUPATH/.$DB-${DATE}.sql.gz_TMP
mv -f $BUPATH/.$DB-${DATE}.sql.gz_TMP $BUPATH/$DB-${DATE}.sql.gz
exit 0 

# example for daily backup (00:01)
# ================================
# add this line to crontab
# 1 0 * * * root sh /path/to/this/script.sh

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...