DontCare 1 Posted March 7, 2015 Share Posted March 7, 2015 Hi Metin2Dev members and admins. I tried to find automatic backup script but I couldn't find. Can you give me this script and quest ? Thanks. Link to comment Share on other sites More sharing options...
DontCare 1 Posted March 8, 2015 Author Share Posted March 8, 2015 Bump 1 Link to comment Share on other sites More sharing options...
wezt 95 Posted March 8, 2015 Share Posted March 8, 2015 Hey, few month ago I've found sh scrip for backups and bit modified it (usable only for linux/unix). So here is a short tutorial: 1) Make next folders on your server: /backup /backup/metin2 2) Make file /backup/backup.sh and put in it next: #!/bin/bash PROJNAME=metin2 CHARSET=utf8 DBNAME01=account DBNAME02=common DBNAME03=player DBFILENAME01=account DBFILENAME02=common DBFILENAME03=player HOST=localhost USER=db_user PASSWD="db_pass" DATADIR=/backup/metin2 SRCFILES=/home/game PREFIX=`date +%F` echo $PASSWD #start backup echo "[--------------------------------[`date +%F--%H-%M`]--------------------------------]" echo "[--START!--][`date +%F--%H-%M`] Run the backup script..." mkdir $DATADIR/$PREFIX 2> /dev/null echo "[+---------][`date +%F--%H-%M`] Generate a database backup..." #MySQL dump mysqldump --user=$USER --host=$HOST --password="$PASSWD" --default-character-set=$CHARSET $DBNAME01 > $DATADIR/$PREFIX/$DBFILENAME01-`date +%F-%H-%M`.sql mysqldump --user=$USER --host=$HOST --password="$PASSWD" --default-character-set=$CHARSET $DBNAME02 > $DATADIR/$PREFIX/$DBFILENAME02-`date +%F-%H-%M`.sql mysqldump --user=$USER --host=$HOST --password="$PASSWD" --default-character-set=$CHARSET $DBNAME03 > $DATADIR/$PREFIX/$DBFILENAME03-`date +%F-%H-%M`.sql if [[ $? -gt 0 ]];then echo "[----------][`date +%F--%H-%M`] Aborted. Generate database backup failed." exit 1 fi echo "[++--------][`date +%F--%H-%M`] Backup database - successfull." #Src dump echo "[+++-------][`date +%F--%H-%M`] Copy the source code project [$PROJNAME]..." tar -czpf $DATADIR/$PREFIX/$PROJNAME-`date +%F-%H-%M`.tar.gz $SRCFILES 2> /dev/null if [[ $? -gt 0 ]];then echo "[----------][`date +%F--%H-%M`] Aborted. Copying the source code failed." exit 1 fi echo "[++++------][`date +%F--%H-%M`] Copy the source code project successfull." echo "[+++++-----][`date +%F--%H-%M`] Prepare zip file $PROJNAME-$PREFIX.zip..." zip -r $DATADIR/$PROJNAME-$PREFIX.zip $DATADIR/$PREFIX if [[ $? -gt 0 ]];then echo "[----------][`date +%F--%H-%M`] Aborted. Make zip file failed." exit 1 fi echo "[++++++----][`date +%F--%H-%M`] Zip file $PROJNAME-$PREFIX.zip finished." echo "[+++++++---][`date +%F--%H-%M`] Remove folder." rm -rf $DATADIR/$PREFIX if [[ $? -gt 0 ]];then echo "[----------][`date +%F--%H-%M`] Remove folder failed." exit fi echo "[++++++++--][`date +%F--%H-%M`] Remove folder finished." echo "[+++++++++-][`date +%F--%H-%M`] Start datadir space (USED): `du -h $DATADIR | tail -n1`" echo "[++++++++++][`date +%F--%H-%M`] Free HDD space: `df -h /home|tail -n1|awk '{print $4}'`" echo "[+SUCCESS!+][`date +%F--%H-%M`] All operations completed successfully!" exit 0 3) And add this line into crontab. Backups will be created each morning at 6am. 0 6 * * * cd /backup/ && sh backup.sh Regards. 1 Link to comment Share on other sites More sharing options...
DontCare 1 Posted March 9, 2015 Author Share Posted March 9, 2015 Hey, few month ago I've found sh scrip for backups and bit modified it (usable only for linux/unix). So here is a short tutorial: 1) Make next folders on your server: /backup /backup/metin2 2) Make file /backup/backup.sh and put in it next: #!/bin/bash PROJNAME=metin2 CHARSET=utf8 DBNAME01=account DBNAME02=common DBNAME03=player DBFILENAME01=account DBFILENAME02=common DBFILENAME03=player HOST=localhost USER=db_user PASSWD="db_pass" DATADIR=/backup/metin2 SRCFILES=/home/game PREFIX=`date +%F` echo $PASSWD #start backup echo "[--------------------------------[`date +%F--%H-%M`]--------------------------------]" echo "[--START!--][`date +%F--%H-%M`] Run the backup script..." mkdir $DATADIR/$PREFIX 2> /dev/null echo "[+---------][`date +%F--%H-%M`] Generate a database backup..." #MySQL dump mysqldump --user=$USER --host=$HOST --password="$PASSWD" --default-character-set=$CHARSET $DBNAME01 > $DATADIR/$PREFIX/$DBFILENAME01-`date +%F-%H-%M`.sql mysqldump --user=$USER --host=$HOST --password="$PASSWD" --default-character-set=$CHARSET $DBNAME02 > $DATADIR/$PREFIX/$DBFILENAME02-`date +%F-%H-%M`.sql mysqldump --user=$USER --host=$HOST --password="$PASSWD" --default-character-set=$CHARSET $DBNAME03 > $DATADIR/$PREFIX/$DBFILENAME03-`date +%F-%H-%M`.sql if [[ $? -gt 0 ]];then echo "[----------][`date +%F--%H-%M`] Aborted. Generate database backup failed." exit 1 fi echo "[++--------][`date +%F--%H-%M`] Backup database - successfull." #Src dump echo "[+++-------][`date +%F--%H-%M`] Copy the source code project [$PROJNAME]..." tar -czpf $DATADIR/$PREFIX/$PROJNAME-`date +%F-%H-%M`.tar.gz $SRCFILES 2> /dev/null if [[ $? -gt 0 ]];then echo "[----------][`date +%F--%H-%M`] Aborted. Copying the source code failed." exit 1 fi echo "[++++------][`date +%F--%H-%M`] Copy the source code project successfull." echo "[+++++-----][`date +%F--%H-%M`] Prepare zip file $PROJNAME-$PREFIX.zip..." zip -r $DATADIR/$PROJNAME-$PREFIX.zip $DATADIR/$PREFIX if [[ $? -gt 0 ]];then echo "[----------][`date +%F--%H-%M`] Aborted. Make zip file failed." exit 1 fi echo "[++++++----][`date +%F--%H-%M`] Zip file $PROJNAME-$PREFIX.zip finished." echo "[+++++++---][`date +%F--%H-%M`] Remove folder." rm -rf $DATADIR/$PREFIX if [[ $? -gt 0 ]];then echo "[----------][`date +%F--%H-%M`] Remove folder failed." exit fi echo "[++++++++--][`date +%F--%H-%M`] Remove folder finished." echo "[+++++++++-][`date +%F--%H-%M`] Start datadir space (USED): `du -h $DATADIR | tail -n1`" echo "[++++++++++][`date +%F--%H-%M`] Free HDD space: `df -h /home|tail -n1|awk '{print $4}'`" echo "[+SUCCESS!+][`date +%F--%H-%M`] All operations completed successfully!" exit 0 3) And add this line into crontab. Backups will be created each morning at 6am. 0 6 * * * cd /backup/ && sh backup.sh Regards. Is this work on FreeBSD ? Thanks. Link to comment Share on other sites More sharing options...
wezt 95 Posted March 12, 2015 Share Posted March 12, 2015 Hey, yes it's perfectly works in freebsd. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now