Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
09-18-2010, 07:08 AM
|
#1
|
Member
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Rep:
|
incremental backup in linux
Hi all,
A complete back up using tar takes consumes more time. so is there any way to take incremental backups using tar.
And i also want to take incremental backup dump of my databases too.
Any suggestions and links will be very helpful.i keep on googling for this,but could find any exact for this.
Thanks in advance,
Dinesh.
Last edited by dinakumar12; 09-18-2010 at 07:09 AM.
|
|
|
09-18-2010, 08:37 AM
|
#2
|
Member
Registered: Aug 2010
Distribution: Fedora, Centos, Debian
Posts: 49
Rep:
|
|
|
|
09-18-2010, 09:42 AM
|
#3
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
Have you tried tar's -g, --listed-incremental option?
Regards the database, the answer will be specific to which database software you are using ... ?
|
|
|
09-23-2010, 01:03 AM
|
#4
|
Member
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Original Poster
Rep:
|
Hi all,
Thank you very much for your reply.sorry for the delayed reply.
We are using both postgres and mysql database.so can any one provide me the command for taking the incremental backup of these two databases.
since i don't even have the basic knowledge in shell script. Your reply would be very helpful.
Thanks in advance,
Dinesh.
|
|
|
09-23-2010, 01:15 AM
|
#5
|
Senior Member
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,638
Rep: 
|
rsync can help you with incremental backup.
|
|
|
09-23-2010, 01:43 AM
|
#6
|
Member
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Original Poster
Rep:
|
hi,
Thanks, but can you provide me the exact code using rsync for taking incremental backup of postgresql and mysql databases.
will be happy if anyone provide me the incremental code for "tar" too.
Thanks in advance,
Dinesh.
|
|
|
09-23-2010, 01:57 AM
|
#7
|
Senior Member
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,638
Rep: 
|
|
|
|
09-23-2010, 03:12 AM
|
#8
|
LQ Guru
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131
Rep: 
|
Here are also a few pages on using rsync to create incremental backups. The first one has a few words on the tar method also, you might want to read them to have an opinion on whether to use it or rsync.
http://www.mikerubel.org/computers/rsync_snapshots/
http://blog.interlinked.org/tutorial...e_machine.html
http://www.sanitarium.net/golug/rsync_backups_2010.html
I happened to work on this just a few days ago, altough not with databases.
Edit: for information on MySQL incremental backups, see for example
http://dev.mysql.com/doc/refman/5.1/...p-methods.html
Quote:
MySQL supports incremental backups: You must start the server with the --log-bin option to enable binary logging; see Section 5.2.4, “The Binary Log”. The binary log files provide you with the information you need to replicate changes to the database that are made subsequent to the point at which you performed a backup. At the moment you want to make an incremental backup (containing all changes that happened since the last full or incremental backup), you should rotate the binary log by using FLUSH LOGS. This done, you need to copy to the backup location all binary logs which range from the one of the moment of the last full or incremental backup to the last but one. These binary logs are the incremental backup; at restore time, you apply them as explained in Section 6.5, “Point-in-Time (Incremental) Recovery Using the Binary Log”.
|
Last edited by b0uncer; 09-23-2010 at 03:15 AM.
|
|
|
09-23-2010, 07:58 AM
|
#9
|
Member
Registered: Dec 2006
Distribution: Slackware
Posts: 933
|
Is using tar for full and incremental backups a hard requirement? If not then...
rsnapshot - http://www.rsnapshot.org/
I've been using this script via cron for a couple years now. I maintain 3 monthly backups, 4 weekly backups and 7 daily backups within about 150% disk space of a single, full backup. Rsnapshot eliminates the need for incremental backups by using rsync and "hard links" to perform full backups in a fraction of the space. Hard links are used with unchanged files and are amazing when it comes to saving space with backups.
Here's a script I run daily to backup mysql databases without shutting down the mysql server. It can be included in the rsnapshot config file. I replaced the server ip with "xxx.xxx.xxx.xxx" and the root password with "root_pswd" for security.
Code:
#!/bin/bash
###########################################################
# Back up MySQL databases
###########################################################
# Do not backup these databases
IGNORE="information_schema mysql test"
# Get list of all databases
DB_LIST=`mysql -h xxx.xxx.xxx.xxx -proot_pswd -Bse 'show databases'`
for db in $DB_LIST; do
# set skip variable
skip=0
if [ "$IGNORE" != "" ]; then
for i in $IGNORE; do
[ "$db" == "$i" ] && skip=1 || :
done
fi
if [ "$skip" == "0" ]; then
mysqldump -h xxx.xxx.xxx.xxx -proot_pswd $db > $db.sql
fi
done
exit 0
|
|
|
09-27-2010, 02:52 AM
|
#10
|
Member
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Original Poster
Rep:
|
Hi chuck,
The script which you have provided for backing up mysql database works like charm,but will feel very happy if i get a similar one for postgresql database too.
|
|
|
09-27-2010, 05:04 AM
|
#11
|
Member
Registered: Dec 2006
Distribution: Slackware
Posts: 933
|
Hopefully a script exists for postgresql. I don't use postgresql (yet) but maybe somebody else might know of a similar type script.
|
|
|
09-27-2010, 05:21 AM
|
#12
|
Senior Member
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,638
Rep: 
|
|
|
|
09-27-2010, 05:22 AM
|
#13
|
Member
Registered: Mar 2008
Location: Malta
Distribution: Slackware and Zenwalk
Posts: 575
Rep: 
|
You might want to consider the dump/restore applications if you only use ext2/3 file systems.
|
|
|
09-27-2010, 06:51 AM
|
#14
|
Member
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Original Poster
Rep:
|
Hi all,
Thank you very much guys, will definetely try this.
once again thank you very much for your replies.
|
|
|
09-29-2010, 09:24 AM
|
#15
|
Member
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Original Poster
Rep:
|
Hi Chuck,
I have another question,if i need to remove the seven days old database dump,what should be added to the script.
Thanks in advance,
Dinesh.
|
|
|
All times are GMT -5. The time now is 04:54 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
|
|