LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-03-2015, 04:26 PM   #1
adumith
Member
 
Registered: Feb 2013
Posts: 44

Rep: Reputation: Disabled
Question Making a DB Backup and send it to another server


Hello everyone;

At this time I need to make a sh script to make a db backup an send it to another server.

Thinking about this, I think I have to:
1.- Make a connection beetween the servers without password
2.- The scrip must to do:
a.- Make the mysqldump
b.- Put it in a gzip file
c.- Send througth scp the gzip file and ONLY when the copy has done the script have to delete the files that are 3 days old.

Could you help me with this?

Do you consider that is a good idea or you have a better one?

Thanks in advance.
 
Old 03-03-2015, 05:24 PM   #2
Kgeil
LQ Newbie
 
Registered: Mar 2014
Posts: 20

Rep: Reputation: Disabled
This looks like a really appealing option: http://wiki.bacula.org/doku.php?id=a..._backups:mysql

I haven't tried it yet, but it's on my to-do list, about 2 weeks out.


HTH,

Kevin
 
Old 03-03-2015, 05:31 PM   #3
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,182
Blog Entries: 10

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
Code:
mysqldump -h <ip> -u<user> p<pass> <db_name> > /path/to/save/file.sql
tar -czf archive_name-$(date +%F).tar.gz /path/to/save/file.sql
for i in `seq 2 31` ; do rm archive_name-$(date +"%m%d%Y" --date="$i days ago") ; done
You should have a user granted perms in mysql just for this purpose or use an existing one (if 'user'@'host' value allows it.
I would NOT use 'user'@'%' like so many are inclined to do)

Other solutions may be more dialed in, I'm tired.
Shout if you need help.

References:
http://www.cyberciti.biz/tips/backup...using-ssh.html
http://bash.cyberciti.biz/backup/bac...base-server-2/

Last edited by Habitual; 03-03-2015 at 05:45 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
making a Multi tape backup wish to send email zimbot Linux - General 2 05-27-2011 12:11 PM
making autosricpt for logging and send them to windows using ftp vodka33us Linux - Server 4 12-18-2008 09:08 AM
Making a backup e-mail server - need help with re-delivery britsky Linux - General 1 04-25-2006 12:55 PM
making java applets send packets videoediting Programming 4 05-03-2005 02:48 PM
Server does'nt send mail until shutdown and LAN can't send or receive. Wolfy Linux - Networking 0 08-02-2004 08:31 PM


All times are GMT -5. The time now is 08:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration