Linux - General This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
12-10-2002, 12:46 AM
|
#1
|
|
Member
Registered: Dec 2002
Location: St. Louis
Distribution: All Flavors
Posts: 190
Rep:
|
Backing up Linux to a remote server!
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.
|
|
|
|
12-10-2002, 02:12 AM
|
#2
|
|
Guru
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,154
Rep:
|
mkdir /backup
mount 192.168.0.1:/share /backup
cd /
tar czvf /backup/slacker-12-10-02.tar.gz . --exclude backup --exclude proc --exclude tmp
|
|
|
|
12-10-2002, 02:23 AM
|
#3
|
|
Member
Registered: Dec 2002
Location: St. Louis
Distribution: All Flavors
Posts: 190
Original Poster
Rep:
|
Quote:
|
mount 192.168.0.1:/share /backup
|
this does what exactly
Quote:
|
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
###################### CONFIG PARAMETERS #############################
ftpuser="someuser"
ftppass="somepass"
ftphost="someserver.com"
date=`/bin/date +%Y-%m-%d`
mysqlpid="/var/run/mysqld/mysqld.pid"
mysqlrootpass="somepass";
#####################################################################
### 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 ""
myisamchk --silent --force --fast --update-state -O key_buffer=64M
-O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M
/var/lib/mysql/*/*.MYI
isamchk --silent --force -O key_buffer=64M -O sort_buffer=64M \
-O read_buffer=1M -O write_buffer=1M /var/lib/mysql/*/*.ISM
fi
###########################################
# Checks finished lets start mysqld again #
# if it doesnt start we need to exit #
# because we wont be able to dump the DB. #
###########################################
echo ""
echo "Starting MYSQLD"
/etc/rc.d/init.d/mysqld start
echo ""
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
done
echo "Making directory $date to upload files to"
touch /tmp/uploadtest
ncftpput -m $ftphost -u$ftpuser -p$ftppass $date /tmp/uploadtest > /dev/null 2>&1
site=`sitelookup -a | awk -F\, {'print $3'}`
for II in $site; do
echo "Creating Pickle and backing up $II"
./createpickle.py $II $ftpuser $ftppass $ftphost | /usr/lib/opcenter/vhbackup/vhbackup
done
|
|
|
|
12-10-2002, 03:36 AM
|
#4
|
|
Guru
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,154
Rep:
|
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.
|
|
|
|
12-10-2002, 03:40 AM
|
#5
|
|
Guru
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,154
Rep:
|
I think that it would not be a bad idea to backup the database with that script or one like it before running the tar backup
the script may not work exactly as is it depends on your database name and location
Last edited by DavidPhillips; 12-10-2002 at 03:46 AM.
|
|
|
|
12-10-2002, 03:41 AM
|
#6
|
|
Guru
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,154
Rep:
|
you can unmount the share after the backup finishes using this
umount /backup
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:59 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|