Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 03-03-2015, 03:26 PM   #1
Registered: Feb 2013
Posts: 46

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, 04:24 PM   #2
LQ Newbie
Registered: Mar 2014
Posts: 27

Rep: Reputation: Disabled
This looks like a really appealing option:

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


Old 03-03-2015, 04:31 PM   #3
LQ Addict
Registered: Jan 2011
Posts: 8,561
Blog Entries: 13

Rep: Reputation: Disabled
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.


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


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 11:11 AM
making autosricpt for logging and send them to windows using ftp vodka33us Linux - Server 4 12-18-2008 08:08 AM
Making a backup e-mail server - need help with re-delivery britsky Linux - General 1 04-25-2006 11:55 AM
making java applets send packets videoediting Programming 4 05-03-2005 01:48 PM
Server does'nt send mail until shutdown and LAN can't send or receive. Wolfy Linux - Networking 0 08-02-2004 07:31 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:49 AM.

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