Results 1 to 9 of 9
-
27th Nov 2011, 11:27 AM #1OPMember
How to: remotely backup your DB (bash script)
hello mateys,
i've put up some basic shell commands (with the help of our beloved lord google the mighty) that will allow you to backup your DBs locally, gzipped it and then send it thru ftp to safe place you've picked
Code:#!/bin/bash mysqldump -uYOURUSERNAME -pYOURPASS -hlocalhost YOURDBNAME > /your/path/backup-`date +%d%m%y`.sql tar -zcvf /your/path/zippedbackup-`date +%d%m%y`.tgz /your/path/*.sql cd /your/path HOST='YOURFTPHOST' USER='YOURFTPUSERNAME' PASSWD='YOURFTPPASS' ftp -n -v $HOST << EOT binary user $USER $PASSWD prompt put zippedbackup-* bye EOT rm -rf /your/path/* exit 0
also don't forget to chmod it first to 755 so that the script can be executed
hope that helps.masterbator Reviewed by masterbator on . How to: remotely backup your DB (bash script) hello mateys, i've put up some basic shell commands (with the help of our beloved lord google the mighty) that will allow you to backup your DBs locally, gzipped it and then send it thru ftp to safe place you've picked #!/bin/bash mysqldump -uYOURUSERNAME -pYOURPASS -hlocalhost YOURDBNAME > /your/path/backup-`date +%d%m%y`.sql tar -zcvf /your/path/zippedbackup-`date +%d%m%y`.tgz /your/path/*.sql cd /your/path HOST='YOURFTPHOST' Rating: 5
-
27th Nov 2011, 11:30 AM #2Member
Be very carefull what you put here, I would even remove that line.
PHP Code:rm -rf /your/path/*
-
27th Nov 2011, 11:37 AM #3OPMember
-
4th Dec 2011, 07:12 AM #4
-
4th Dec 2011, 07:39 AM #5
-
4th Dec 2011, 09:11 AM #6MemberWebsite's:
freshimg.com: command not found:
: command not found:
: command not found1:
: command not found4:
: Name or service not known
Not connected.
Not connected.
Not connected.
?Invalid command
: command not found2:
: numeric argument required 0
so it mean ftp is installed and working
remote ftp account with putty
-
4th Dec 2011, 12:59 PM #7OPMember
try login on ssh
then type ftp
-
6th Dec 2011, 05:36 AM #8Member
@Masterbator, I don't need the FTP, I will manually download it everyday, but I just need the script to zip the site folders and mysql into one location. Did I modify your script correctly? And this is for Centos 5-6?
I'm using fake user/pass and locations, so no worries.
Code:#!/bin/bash mysqldump -uLudo8 -pludo8 -hlocalhost ludodb > /var/www/mysite-`date +%d%m%y`.sql tar -zcvf /var/www/mysite/backups-`date +%d%m%y`.tgz /var/www/mysite/backups*.sql exit 0
-
6th Dec 2011, 05:54 AM #9OPMember
this works for any linux distro mate
i think this script will work for your purpose:
Code:#!/bin/bash mysqldump -uLudo8 -pludo8 -hlocalhost ludodb > /var/www/yoursite/DB-`date +%d-%m-%y`.sql tar -zcf /var/www/backupfolder/yoursitefull-`date +%d-%m-%y`.tgz /var/www/yoursite/* exit 0
and download your full backup (DB+site) from there (the yoursitefull.tgz file)
doesn't matter, it will work with or without a space
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
bash script mass download from links in text file
By Mutikasa in forum Tutorials and GuidesReplies: 1Last Post: 9th May 2012, 04:20 PM -
OpenVPN For VZ VPS Bash Script. "CentOS"
By dotvps in forum Tutorials and GuidesReplies: 4Last Post: 28th Feb 2012, 01:07 PM -
mass upload bash script (good for Megaupload)
By Mutikasa in forum Tutorials and GuidesReplies: 7Last Post: 13th Jan 2012, 12:54 PM -
ssh/bash script
By t3od0r in forum Technical Help Desk SupportReplies: 0Last Post: 6th Oct 2010, 06:41 PM -
Need A Bash Script
By orbofdarkness in forum Technical Help Desk SupportReplies: 14Last Post: 8th Feb 2010, 08:02 PM
themaLeecher - leech and manage...
Version 5.03 released. Open older version (or...