12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
#!/bin/bashTARGET=/BACKUPexport DT=`date +"%Y%m%d_%H%M"`export DESTDIR=${TARGET}/`date +"%Y%m%d/mysql"`TMPNAME=_dump_sql_tmp_$$function Backup(){local SERVERSER
以下为本文的正文内容,请查阅,本站为公益性网站,复制本文以及下载DOC文档全部免费。
#!/bin/bash
TARGET=/BACKUP
export DT=`date +"%Y%m%d_%H%M"`
export DESTDIR=${TARGET}/`date +"%Y%m%d/mysql"`
TMPNAME=_dump_sql_tmp_$$
function Backup()
{
local SERVER
SERVER=$1
BASE="$SERVER"_${DT}
CURDIR=`pwd`
echo " ${SERVER} to ${BASE}: "
DEST=${DESTDIR}/${SERVER}/${DT}
mkdir -p ${DEST}
cd ${DEST}
# getting list of databases...
echo "SHOW DATABASES;" | mysql -pPASSWORD -u USER -h ${SERVER} > ${TMPNAME}
while read DB
do
if [ $DB != "Database" ]; then
echo -n " ${DB}: "
mysqldump -Q --all --complete-insert --quote-names --add-drop-table -pPASSWORD -u USER -h ${SERVER} ${DB} >${BASE}_${DB}.mysql
echo -n "md5"
md5sum -b ${BASE}_${DB}.mysql >${BASE}_${DB}.md5sum
echo -n ", tar"
tar --remove-files -zcf ${BASE}_${DB}.tgz ${BASE}_${DB}.*
echo ", md5"
md5sum -b ${BASE}_${DB}.tgz >${BASE}_${DB}.md5sum
fi
done < ${TMPNAME}
rm -f ${TMPNAME}
cd ${CURDIR}
echo "Done."
}
# Call for all your servers
Backup localhost
Backup my.othersever.com
#!/usr/bin/perl#mysql_backup.cgi####################################################################################PODDocumentation=head1PROGRAMNAMEANDAUTHORMySQLBackupv3.3byPeterFalkenbergBrownpeterbrown@worldcommunity.comhttp://worldcommunity.com/opensource/BuildDate:September14,2008=PURPOSEBacksupmysqldatasafely,using'mysqldump','selecttooutfile'or'normalrecordselection'.Thisismyattempt:-)toprovideareasonablyfullfeaturedMySQLbackupscriptthatcanberunfrom:1.LinuxCrontaborWindowsScheduler2.theshellorcommandprompt3.theweb(withpasswordprotection)(NotethatIdon'trecommendrunningitfromthewebbecauseofpermissionissues-however,someusersdon'thaveshellaccess.Itdependsuponthesecuritylevelofyourdata.ItnowworksfrombothLinuxandWindows.SeeURLsattheendaboutwheretogetWINDOWSVERSIONOFUNIXUTILITIES.Itprovidesoptionstobackupallofthedatabasesandtablesinoneparticularhost,withexceptionlists.Itnowhastheabilitytoselectavarietyofoptionsforthetarandgzipfunctions,includingusingthetar-zswitch,usingbzip2andpipingdatathroughgzip/bzip2.Italsodeletestextfilesinbetweentarandgzip,tosavespace.Italsoworksaroundthesqlwildcardglitchwithunderlines(_),intablenames,bynotusingmysqlshowtogettablenames.Ididthis,becausemysqlshowdb%didn'tworkunderMySQLv3.22.20a,andIwasn'tabletodeterminewhenthe%methodcameintobeing(underwhichversion.)So,inordertomakethingsworkforearlierversions,Iused'showtables'.(Istillusemysqlshowfordatabasenames.)=COPYRIGHTCopyright2000-2008PeterFalkenbergBrown(WCP-TheWorldCommunityPress)ThisprogramcomplieswiththeGNUGENERALPUBLICLICENSEandisreleasedas"OpenSourceSoftware".NOWARRANTYISOFFEREDFORTHEUSEOFTHISSOFTWARE=BUGREPORTSANDSUPPORTSendbugreportstopeterbrown@worldcommunity.com.=OBTAININGTHELATESTVERSION==>Getthemostrecentversionofthisprogramat:http://worldcommunity.com/opensource/=TODO-addingmultiplerecipientsupportEmailyourfeedbackandideasto:peterbrown@worldcommunity.com=VERSIONHISTORY(Seethebottomofthefile,sincetheversionnotesaregettinglonger.)=cut###################################################################################useDBI;usePOSIXqw(strftime);useTime::Local;useCwd;useFile::Path;#.............................................................#ifyou'renotgoingtousethescriptfromtheweb#youcancommentoutthenext3CGIlines,ifyoudon'thave#CGI.pminstalled.useCGIqw(:all-private_tempfilesescapeHTMLunescapeHTML);useCGI::Carpqw(fatalsToBrowsercluck);$q=newCGI;#.............................................................nostrict'refs';#MANDATORYVARIABLESETUPSECTION#..................................#Note:thefileisALWAYSsavelocally,whetherornot#yousetftp_backupand/oremail_backupto'yes'$ftp_backup='no';useNet::FTP;#set$ftp_backupto'yes'or'no'.#=>NOTE#Ifyousetitto'yes',#you'llneedtoinstallNet::FTP#Ifyoudon'tinstallNet::FTP,#youMUSTplaceacomment(#)infrontof#the'useNet::FTP'lineabove#You'llalsohavetosetthevariables#forftphost,etc(below)$email_backup='no';useMIME::Lite;#somemailinghostschokeiftheattachmentis#toolarge;youmayhavetousetheftpmethod#ifthatistrue#set$email_backupto'yes'or'no'#=>NOTE#Ifyousetitto'yes'#you'llneedtoinstallMIME::Lite#Ifyoudon'tinstallMIME::Lite,#youMUSTplaceacomment(#)infrontof#the'useMIME::Lite'lineabove#SeeWindowsUsersNotebelow#aboutMIME::Lite(Youneedit.)#Gotosearch.cpan.orgtogetthelibs.#MicrosoftWindowsoptions#..................................#useNet::SMTP;#COMMENTouttheuseNet::SMTPline#ifyou'renotusingsmtp#NOTEforWindowsUsers:#-adjustthe$find_commandssectionbelow#(set$find_commandstono)#-you'llneedtoinstallWindowsversions#oftheutilitieslistedinthefind_commands#section-seetheurlsattheendofthefile#-notealsothatyourwindowssystemmayrequirethat#libintl-2.dllandlibiconv-2.dllbeinstalledin#yourc:windowssystemdirectory(fortar,I#believe)Idownloaded"libintl-0.11.5-2-bin.exe",#fromgnuwin32.sourceforge.net/packages/libintl.htm#andwentthroughtheinstallation,butthenhadto#copythetwofilesbyhandfromtheirdefault#installationdirectory,overtothe#windowssystemdirectory.#--don'tbotherinstallingthemunlessyoureceive#anerrormessage-IonlytestedthisonWin98.#-set$chmod_backup_fileto'no'#-setthesmtpitemsinthissection#-installMIME::Liteanduncommentthe#useMIME::Litelineabove#-thetarzswitchandthetar/gzippipemethod#don'tworkonWindows#-theshellcommandlengthonWin98is127#(althoughyoucanincreaseitbyinstalling4Dos)#--thus,forWin98,youmaywishtoinstall#yourutilitiesinashortdirlikec:bin#andmakeyourbackupdirshortalso,#likec:data#--ForWin98(atleast)usethe$max_cmd#variabletoabortoncommandsthatare#longer.$max_cmd=0;#(forWindowsUsers,especiallyWin98)#(forWin98setthisto'127')#setthisto'0'ifyoudon'tneedtocheckthe#lengthofyourshellcommandstrings#(seethe`backtickcommands)#$mailprog="/var/qmail/bin/qmail-inject-h";#$mailprog='/usr/lib/sendmail-t-oi';$mailprog='/usr/sbin/sendmail-t-oi';#sendmailismorecommon#butqmail(qmail.org)is(was?)better:-).#but..qmaildoesn'tworkonwindows#I'vehadagoodexperiencewithPostfix(asof2008).$smtp_host='your.mailserver.domain.or.ip';#setonlyifyousetsend_methodto'smtp'#(usefulforWindows)$send_method='sendmail';#set$send_methodto'sendmail'or'smtp';#(oftensettosmtpforWinX)$admin_email_to='you@yourdomain.com';#theemailforerrorandnotification#messages,andtheemailrecipient#ofthedatabasefiles.$admin_email_from='you@yourdomain.com';#databaseoptions#..................................$web_test_database='my_database';#Thenameofyourauthorizeddatabase.#Seethenotesbelowaboutlogginginfromtheweb.#.....................................................#Becausetheloginmusttestthemysqlauthorization#againstaspecificdatabase,thisnewvariable#isrequired**ONLY**whenlogginginfromtheweb.#UsethenameofANYdatabaseforwhichyour#loginusernamehasauthorizedaccess.#NOTE!ThisdatabasenamehasNOrelationshiptothe#--@selected_databasesand#--$process_all_databasesvariables#YoustillMUSTsetthosevariablescorrectly.#The$web_test_databasevarisONLYused#foraninitiallogintest.#NOTE!Theusermustbeauthorizedforthe#testdatabaseANDthedatabasethatyouplace#intheselected_databasearray#IftheuserisNOTauthorizedforboth,#thescriptmightpassthefirstlogintest,#butfailonthespecificdatabaselogin,#whichwouldhappenAFTERthecreationofthe#backupdirectory(whichismessy).@selected_databases=qw[];#placethenamesofyourdatabaseshere,#separatedbyspaces,orset#process_all_databasesto'yes'$process_all_databases='yes';#@selected_databasesisignoredifyouset#process_all_databasesto'yes'#Manyserverswithvirtualhostsallowyou#toseeallofthedatabaseswhileonlygiving#youaccesstoyourowndatabase.Inthatcase,#placethenameofyourdatabaseinthe#@selected_databasesarray.#Someoneelsemightwanttoprocessallofthe#databases,withpossibleexceptions.Ifso,#placethedatabasestoskipinthe#skip_databasesarraybelow.@skip_databases=qw[];#Note:skip_databasesisonlyparsed#ifprocess_all_databasesissetto'yes'#Leaveitblankifyoudon'twanttouseit.,i.e:#qw[];@skip_tables=qw[];#skip_tablesisalwaysparsed.#Leaveitblankifyoudon'twanttouseit.,i.e:#qw[];#Thismaybeanissuewithduplicatetablenames#inmultipledatabases--it'sonthetodolist.$password_location='cnf';#NEWOPTIONFORPASSWORDLOCATION:#'from_web'ALLOWSWEBLOGIN#.................................................#setto'cnf'or'this_file'or'from_web'#.................................................#NOTE!!IhaveNOTtestedcnfunderWindows.#.................................................#theconnectionsubroutineusesthis#todecidewhichmethodtouse.#I'veaddedfunctionalitythatallowsthescript#toberunfromtheweb,becausesomeusers#don'thaveshellaccess.#if$password_locationissetto'from_web',#thenncharsaretranslatedtoandalso,a#"Content-type:text/htmlnn";isprintedtosdtout.#notethatyou'llhavetoeitherrunthe#.cgifilefromyourwebtree,orusea'stub'file#whichIrecommend.(seemywebpageforanexample).#NOTE!!!RUNNINGFROMTHEWEBispredicated#onanumberofissues:#-webloginsdon'tuseacnffile,since#thecnffilewouldberequiredtobeworld#readable,andbecausewehavetocheck#theuserloginanyway,againstmysql.#-thebackupdirectory($mysql_backup_dir)#mustbewriteablebythewebserver#(sinceit'soutsidethewebtreeandthe#thescriptrequiresalogin,therisk#iscontrolled--however,ifyourserver#co-existswithothervirtualservers,#youshouldmakesurethattheycan'tftp#outsidetheirownhomedirectory.)#-set$chmod_backup_fileto'no'#sincefileswillbeownedbywebserver#andifthey'resetto600youwon'tbeable#todownloadthem#-dependingonwhichuseryouloginas#(superuserorsingleuser)#youmaynothavepermissionto#backupdatabasesotherthanyourown;#thus,set#--@selected_databasesand#--$process_all_databasescorrectly.#-mysqluserpermissionswillalsoinfluence#whetherornotyoucanuse#the'selectintooutfile'methodofbackup#--trymyslqdump...#--ifallelsefails,use'normal_select'#-NoteaboutSSLandWeblogins:#Ifyou'vegotansslurl,useit!#It'sworthittoencryptyourdatabase#usernameandpassword.#(Justrunthescriptprefixedby#https://yourdomain.com/script_name.cgi)#SSLNote2:Evenifyoudon'tOWNanSSLCert,#youcanoftenusethehttpssslsyntax;#thewebserverwillencryptitanyway;#itsimplywarnsyouthatyoudon'thave#ansslcert.Whatdoyoucare:-)?#(You'retheonerunningthescript.)#TheCert/BrowsermarriageisaSCAM#inmyopinion.Sincetheencryption#happensanyway,thestupidwarningbox#shouldbeeliminated.MaybeaCongressional#sub-committeeshouldinvestigateit:-).#IfyouwantaCHEAP,FAST,cert,goto:#http://instantssl.com(approx.$40!)$login_script_name='mysql_backup_login.cgi';#thisisthenameofthescriptthat'sused#forweblogin--eithertherealscript,#orastubscript#Ifyou'renotusingtheweboption,#youcankeepitblank,orwhatever.#Seeourwebsiteforanexamplestubscript.$chmod_backup_file='yes';#setto'yes'ifyouwanttouseit#(youDONOTwanttosetthebackupfileto600#unlessyoucanftpinastheuserthat#thescriptrunsas.(seewebuseabove)#..............................................................................#dbhostinformation#set$db_hosttoaremoteserverifyouneedtoaccessdata#onadifferentmachine.$db_host='localhost';#or,useadomainnameorip#fordatabasesondifferentmachines$db_port='3306';#databaseconnectionvariables$cnf_file='/home/yourdomain.com/.my.cnf';#useanabsolutepath;~/maynotwork$cnf_group='client';#youcanstoreyourusernameand#passwordinyourcnffile#or..youcanplacetheusernameand#passwordinthisfile,#butyoushouldsetthisto700(rwx------)#sothatit'smoresecure.#weassumeherethatyourusernamestatus#equalsthefunctionsneeded.#(forexample,'selecttooutfile'#requiresfileprivileges.)#NEWINV3.0!#Inowlongerparsethecnffilemanually.#(Iactuallydidn'tusetheparseddata#in2.7,butIhadn'tdeletedthecode.)#Ifyouselectcnf_file,mysqlshowandmysqldump#willusethecnf_groupvariable#thus,yourcnffilecaninclude#multiplegroupsifyouwish.#CNFFILECONTENTS:#[group_name]#user=yourusername#password=yourpassword$user='';$password='';#$ENV{'MYSQL_UNIX_PORT'}='/var/lib/mysql/mysql.sock';#useanabsolutepath;~/maynotwork#especiallywithcrontab.#$ENV{'MYSQL_UNIX_PORT'}#canbeusedundertwocircumstances:#1:Whenyouhavemultipleinstancesofthe#MySQLdaemonrunningonyourhost,#whereeachinstanceofthedaemon#hasitsownmysql.sockfile-Therefore#thescriptneedstofindthesocketfile.#2:IfyourMySQLsocketfileisNOT#inadefaultdirectory,suchas:#/var/lib/mysql/mysql.sock#thenyoumayneedtousetheabove#environmentcommand.#IfyouusethenormalMySQL#installation,youcanCOMMENTOUTtheaboveline$site_name='YourDomain.com';$subject="MySQLBackupDonefor$site_name";#subjectistheemailsubject$mysql_backup_dir='/home/yourdomain.com/mysql_backup';#useanabsolutepath;~/maynotwork#thebackupdirshouldnormallybe#OUTSIDEofyourwebdocumentroot#thisdirectorymustbewritablebythescript.#Ifyoubackupfromtheweb,thenthisdirectory#shouldbesetto777.(seewebnotesabove)#MANDATORYUTILITYPATHSETTINGS#..................................$find_commands='yes';#Set$find_commandsto'yes'or'no'#dependinguponwhetheryouwanttohavetheprogram#searchforthecommandlineutilities.#Thisisaweakattemptata./configureconcept.#Doweneedit,sinceonecaneditthelinesbelow?#Probablynot.:-)#WINDOWSUSERS:NOTE:#Set$find_commandsto'no'andeditthe#pathvarsdirectly--whereisdoesn'texist#onWinX(itshould:-).#Seethenotesattheendofthescript#aboutwheretodownload#WINDOWSVERSIONOFUNIXUTILITIES.#Afterinstallingthem,editthepathsinthis#section.Use/forwardslashes.#Ifyouwanttousedifferentutilities,simply#usethismanualmethodofsettingthepaths(below)#andalsochangetheutilityname.Note,however,#thatyoushouldthenchecktheparameterstothe#utilitiesusedinsidethescript.#THISISWHEREYOUMANUALLYSETTHEPATHSTO#THEUTILITIES#...............................................if($find_commandseq'no'){$mysqlshow_cmd='/usr/bin/mysqlshow';$mysqldump_cmd='/usr/bin/mysqldump';$nice_cmd='/bin/nice';$tar_cmd='/bin/tar';$gzip_cmd='/bin/gzip';$bzip2_cmd='/usr/bin/bzip2';$ls_cmd='/bin/ls';#windowsexamples(useashortdirectory-seewindowsnotesabove)#NOTE!!forWindows,youMUSTincludethe.exesincethescript#checkstoseeifthefileexistsbeforerunning.#$mysqlshow_cmd='/bin/mysqlshow.exe';#$mysqldump_cmd='/bin/mysqldump.exe';#$nice_cmd='/bin/nice.exe';#$tar_cmd='/bin/tar.exe';#$gzip_cmd='/bin/gzip.exe';#$bzip2_cmd='/bin/bzip2.exe';#$ls_cmd='/bin/ls.exe';#seewindowsnotesaboveaboutlibintl-2.dllandlibiconv-2.dll#youmayneedtoplacetheminyourwindowssystemdirectory.#(Ineededto,underWin98.)}#...............................................#theautomatedmethodisdoneinthemainbodyof#thescript$compress_method='';#(blank)'',or'z_switch'or'pipe_method'#NOTE!!!Thezswitchandthepipemethod#don'tworkonWindows#useeither'z_switch'(fortar-z),or#'pipe_method'forpipingthroughgziporbzip2,or#''(blank)forthetwostepmethod#(firsttar,thengzip)#Notethatifyouset$delete_text_files#to'yes'(below)#thenthetextfileswillbedeleted#BETWEENthetarandgzipcreation,ifthe#compress_methodissetto''.#(thussavingdiskspace)#Otherwise,thetextfileswillbedeleted#afterthegzipfileiscreated,usingthe#zswitchorpipemethod.$delete_text_files='yes';#setdelete_text_filesto'yes'ifyouwantto#deletetheintermediatedatatextfiles,#andonlykeepthetar.gzipfiles.#Irecommendthis,becausethetextfiles#canbelarge.$use_bzip2='no';#Ifyouset'use_bzip2'to'yes'#thenitwillbeusedinsteadofgzip,#UNLESS!!#$compress_methodequals'z_switch'#(becausethe-zswitchusesgzip)#Ifsetto'no',thescriptwon'tcheck#forbzip2atall(soyoudon'tneediton#yourdisk)$gzip_args='-9v';#setgzipargumentsifyoulike#-1--fastcompressfaster#-9--bestcompressbetter$bzip_args='-9v';#setbzip2argumentsifyoulike#-1..-9setblocksizeto100k..900k####################################################################################OPTIONALVARIABLESSETUPSECTION#(Youmaynotneedtochangethevarsbelow)###################################################################################$show_file_list_in_email='no';#forlargedirectoriesthisshouldbesetto'no'$print_stdout='yes';#setthisto'yes'ifyouwanttoprint#messagestothescreen,setitto'no'if#youonlywantthemessagetogotoemail#Notethattheprintstatementsare#createdwithasubroutinecall&message#&message('s/e/b','somemessagetext';#S=stdout,E=email,B=both#Thus,youcanselectivelymodifyeach#&messageprintstatementifyoulike.#(screenoutputcanonlybeselectively#modifiedif$print_stdoutequals'yes')$date_text=strftime("%Y-%m-%d_%H.%M.%S",localtime);#thedate_textvarbecomespartofthebackupfile#name.seenotesabout'backup_date_string'atend#offile$increments_to_save=5;$seconds_multiplier=86400;$increment_type="Day(s)";$seconds_to_save=$increments_to_save*$seconds_multiplier;#increment_typeisusedforthetextoutput,#andhasnoimpactonthemath.#onecouldsetincrementtypeto"Minute(s)"#or"Hour(s)"or"Day(s)"or"Week(s)",etc.#Justsettheseconds_to_savenumberto#thecorrectnumberofseconds,i.e:#minute:60/hour:3600/day:86400#week:604800#thesevariablescontrolhowmanyincrements#(e.g.'days')worthof#backupfilestosave.Fileswith#timestampsolderthanthiswillbedeletedeachtime#thescriptisrun.Notethatthefilemodification#timeisused-NOTthefilename.#Thismayhavetobemodifiedonnon-Linuxboxes.$space_line=""x5;#variableusedforspacesatthebeginning#ofsomelinesofprintedoutput#ifyouaren'tgoingtoftpyourbackupfiletoasecondserver,#youdon'tneedtosetthesevariables.$ftp_host='ftp.your_offsite_domain.com';$ftp_port='21';$ftp_passive='1';#setto'0'(false)or'1'(true)#youmayneedtousepassiveftptransfersifyou#usesshtunnelingforftp.#Normally,youhavetoconnectwithsshfirst,#totheremoteftphost,usinganIPnumberand#port21forthelocalandremotehost.#Youthenuse'localhost'intheftpscript#(i.e.$ftp_hostabove)andset$ftp_passiveto'1'.#Notethatthisscriptwouldneedanadditionto#fireupsshfirst,andthendisconnectsshafterward.#(perhapsinthenextversion).#whenImanuallyfiredupsshfirst,with#tunnelingset,theftppassivefunctionworkedfine.$ftp_user='your_username';$ftp_password='your_password';$ftp_dir='/your_offsite_domain_backup_dir/mysql_backup/';#NOTE!!!!##ThisshouldbesettotheABSOLUTEPATH##sothatthedeleteoldfilesroutineworks.##Thatis,youshoulduseabeginningslash/.#NOTE!!!!##Youmustalsouseatrailing/becauseof##thedoublecheckwithpwd()beforetheoldfiles##aredeleted.#ForWinXusers:#NotethattheuploaddirectoryunderWin98#usingthefreeCerberusFTPservercorrectlyused#longdirectorynames,usingeitheror/for#directorydelimiters.Cerberusisat:#http://www.greenepa.net/~averett/cerberus.htm$delete_old_ftp_files='yes';#deleteoldftpfilesornot$number_of_files_to_save=5;#Numberoffilestokeeponremoteftpserver.#NotethatIdon'tusedateprocessingtokeep#filesolderthanacertaintime,becauseofpotential#differenceswithtimezonesandremoteservertime#changes.Sincewecan'tcontrolwhattheremotetime#is(unlikethelocalserver),Iusedtheconceptof#keepingacertainnumberoffilesintheremoteftp#directory,usingthelistoffilessortedbymost#recentlyuploadedfirst.Thus,ifyoukeep3,the#the3thatwillbesavedarethemostrecent3.#Thisnumbercan'tbelessthan1.$tar_options='-pv';#hardcodedoptionsinclude'c,f'#p=retainpermissions#v=verbose(canbesetbelow)if($show_file_list_in_emaileq'yes'){$tar_options.='-v';}#backupfileprefix$file_prefix='bak.mysql';#thefileprefixisalsousedtomatchfiles#forthedeletionofoldfiles.It'sareal#'PREFIX',itwillbeplacedatthefrontof#eachfilename#mysqldumpvariables#..................................$mysql_dump_file_ext='txt';#NOLONGERUSED!!#$mysqldump_params='--quick--add-drop-table-c-l';#NOLONGERUSED!!#NOTE!!!Thevariable$mysqldump_params#isNOLONGERUSED!!!#BecauseIrunmysqldumpfromthesystem#command,I'vehardcodedtheabovevalues#inthesystemcall,inthesubroutine#do_backup.I'veleftthemheresofolkscan#seethisnote.Ifyouwanttochangethe#abovevariables,thengotothesystem#callundermysqldumpinthedo_backupsubroutine.$backup_type='mysqldump';#$backup_type='outfile';#$backup_type='normal_select';#set$backup_typetooneofthese3types:#'mysqldump'#'outfile'#'normal_select'#(mysqldumpisthebestchoice,followedbyoutfile)#!NOTE:forthe'outfile'method,#youmusthaveMySQLfileprivilege#status,orthefilewillnotbewritten#(itwillbe0byteslong)#'normal_select'usesanormal#select/writeprocess;it'sclunky,#butsomehostsdon'tprovideaccessto#mysqldumpor'selectintooutfile'#(sometimesmysqldumpisonadifferent#server,andsometimesauserdoesn'thave#'file_privileges'formysql.)#NOTE:forLARGEdatasets,'normal_select'#maynotworkwell,becauseofmemoryproblems$backup_field_terminate='|';$backup_field_enclosed_by='';$backup_line_terminate=":!:n";#paramsfor'normal_select'filewriting#notethatthe"n"mustbeinterpolated#via"doublequotesortheqqmethod#Iuse:!:ninordertoaccomodate#textorblobfieldsthathavelinefeeds.$outfile_params=qq~fieldsterminatedby'|'linesterminatedby':!:n'~;#paramsfor'select*from$table_name#into$outfile($outfileiscreatedin#thebackuproutine)#endofmysqldumpvariables#...........................#ENDOFSETUPVARIABLES####################################################################################YOUNORMALLYWON'THAVETOMODIFYANYTHINGBELOWTHISLINE####################################################################################webloginroutine#..........................................if($password_locationeq'from_web'){print"Content-type:text/htmlnn";if(param('w_user')=~/w+/andparam('w_password')=~/w+/){#testforauthorizedaccess&connect_to_db($web_test_database);#ifwegettohere,itmeansthatwe'reauthorizedprintqq~
11-19
11-19
11-19
11-19
11-19
11-19
11-19
11-19
11-19
11-19
11-19
11-19
11-19
11-19
11-19
11-19