Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
#DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')" #This line is to backup all databases.
DBS=("DBname") #To Backup only specified databases use this line.
for db in ${DBS[@]}
do
FILE=$BAK/$db.$NOW-$(date +"%T").gz ##NOTE: To save some disk space the sql dump files are compressed using gzip;
$MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE ## You can uncompress them using the command "gzip -d <FILENAME>"
done
till here i am getting back up correctly. i am confused here at . i need this DB to stored in filesystem in a specific folder /DBback . and i need script to place in crontab.
Please give me some solution.
Actually this is completed code. next lines in this script are copying the Db's to FTP server
once gain i am sending the complete the script for reference.
### MySQL Server Login Info ###
MUSER="user"
MPASS='#####'
MHOST="localhost"
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
BAK="/home/foldername
GZIP="$(which gzip)"
NOW=$(date +"%d-%m-%Y")
### FTP SERVER Login info ###
FTPU="FTPuser"
FTPP="passwd"
FTPS="hostname"
#DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')" #This line is to backup all databases.
DBS=("DBname") #To Backup only specified databases use this line.
for db in ${DBS[@]}
do
FILE=$BAK/$db.$NOW-$(date +"%T").gz ##NOTE: To save some disk space the sql dump files are compressed using gzip;
$MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE ## You can uncompress them using the command "gzip -d <FILENAME>"
done
In this code . please guide in which line do i need to add the code to create the folder with time stamp.
I just need to take back up and save the files in same server not in the remote server.
Please give me some solution.
and you will have multiple files with date&time stamp in your "BAK="/home/foldername" directory
and don't forget to close " at BAK="/home/foldername" (<-- like this) as your code is missing closing quote "
If you don't want to FTP the files then comment out:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.