Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
For 3 hours im searching for this answer and came across this website. Which Im glad to cause im a newb to linux and prefer it over any O/S so I might frequent this board a lot.
Dont flame me as I dont really know where to post this since Im new here
Here is what i'm looking for...
I want to backup the entire server, onto another server. Files, Configurations, Email, SQL Databases, EVERYTHING basically take an image of the current drive, and upload it to another server.
My client asked me if I could make a script that would do just this but he wants it to shut down current processes, create an archive of the backup, taring and gziping everything, so when you unzip, it would unzip back to its original state, and upload it to a remote server, and set this up as a cron job. I think he's asked the impossible as I cant really think of a way to make a shell script that would disable any current processes, and start the backup. The archive used for backup, id prefer tar.gz
Any help would be SOO greatly appreciated as Im exhausted looking for the answer.
tar czvf /backup/slacker-12-10-02.tar.gz . --exclude backup --exclude proc --exclude tmp
and this backsup the entire server/configs/database?
Im looking at this script right now that might do the trick but im very leary of it.. think it will work??
PHP Code:
#!/bin/sh
###################################################################### # Automated backup script of mysql and user sites for ensim 3.0. # # This script will dump the default database structure and data using# # mysqldump to the sites root directory. # # This script will only backup the DEFAULT mysqldb created when you # # add the user in the format of domain_tld. # # # There is no warranty, i hold no responsibility for any damage you # # cause by not knowing what you are doing. # ######################################################################
###################################################################### # Script configuration you must enter valid FTP information # # This script will connect to server VIA ftp and make the directory # # where the backup files will be uploaded. The directory is in the # # format of YYYY-MM-DD/ the backscript. It will then execute # # createpickle.py and pass ite the ftp arguments! # # # # You must also specify the mysqld root pass in order to dump the # # users database and back it up to there home directory before the # # backup. # ###################################################################### PATH=/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
##################################################################### ### DONT CHANGE ANYTHING BELOW UNLESS YOU KNOW WHAT YOU ARE DOING ### #####################################################################
###################################################################### # Check to see if the ftp info is valid otheriwse exit # ######################################################################
FTP=`ncftpput $ftphost -u$ftpuser -p$ftppass ./ /tmp/uploadtest >/tmp/.ftptest 2>&1` check=`/bin/cat /tmp/.ftptest| grep 'not accepted'` if [ -n "$check" ]; then echo "FTP USER / PASS not accepted exiting....." exit 1; fi
############################################################################ # Check mysql databases and tables fix corrupted databases using myisamchk # # and isamchk We must first stop mysqld it should only take a few minutes # ############################################################################
########################## # Attempt to stop mysqld # ##########################
mysqladmin -p$mysqlrootpass shutdown
if [ -f $mysqlpid ]; then echo "mysqld couldnt be stopped exiting.. "; exit 1; else echo "Mysql has been stopped will checking MYI and ISM tables for every user DB" echo "" echo ""
########################################### # Checks finished lets start mysqld again # # if it doesnt start we need to exit # # because we wont be able to dump the DB. # ###########################################
if [ -f $mysqlpid ]; then echo ""; else echo "Mysqld didnt start please start it... exiting...." exit 1;
fi
########################################################################### # Backup user databases by using mysqldump and gzipping it too # # /home/virtual/domain.xxx/mysql-domain_xxx.gz # ###########################################################################
mysql_db=`sitelookup -a | awk -F\, {'print $1'} | tr "." "_"` for II in $mysql_db; do db_dir="/var/lib/mysql/$II" if [ -d $db_dir ]; then domain=`echo $II | tr '_' '.'` echo "Backing up mysql db $II" mysqldump -p$mysqlrootpass $II | gzip >/home/virtual/$domain/mysql-$II.gz else echo "$II Doesnt Exist skipping to next..." fi
for II in $site; do echo "Creating Pickle and backing up $II" ./createpickle.py $II $ftpuser $ftppass $ftphost | /usr/lib/opcenter/vhbackup/vhbackup done
the mount command would mount an nfs share on the computer that you are putting the backup on
if it's a MS windows machine you could change that to mount a windows share
the tar command will backup the entire system to the computers hard drive that you mounted with the exception of the backup folder itself, the proc folder, and the tmp folder
you do not backup a proc folder because it is dynamic, however you do need the empty folder there if you restore a system
I guess you could use --exclude proc/*
so the folder would be in the backup
you could also do the same with the tmp folder or just backup the whole tmp folder if you want.
Last edited by DavidPhillips; 12-10-2002 at 03:37 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.