S
S
Sergey2013-11-19 12:47:32
linux
Sergey, 2013-11-19 12:47:32

Why is there a problem with tar when backing up?

Hello. There is a server at home that broadcasts sites to the network.
There is also a backup script, self-written, which is run by cron every day at night.
He backs up the files, making a tar.gz archive, copying it to another disk.
The problem is that if something changes in the folder that tar is compressing at this point, tar will crash with an error [tar] file changed while reading . Of course, the backup is not complete.
Since sites are broadcast, either the cache is constantly changing there, or the contents of the uploads folder, into which the framework loads pictures that users post, for example. Or the logs change.
If you can put exceptions on the logs and cache, then you can't put exceptions on the uploads folder, because these files are part of the content and they are needed. And to have the probability of not a complete backup is not encouraging.
And how to be and what to do?
Please advise.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
K
ksand, 2013-11-19
@butteff

1. rsync -qWaup /path/to/side_dir /backup/ #correct if there is room for a full duplicate
tar -cjf backup_site`date +%y%m%d`.tar.bz2 /backup/site_dir
2. lvm snapshot 8 ) provided that lvm is used

V
Vlad Zhivotnev, 2013-11-19
@inkvizitor68sl

apt-get install archivemount
mkdir -p /backup/archive/
touch /backup/backup-$(date +%s).tar
archivemount /path/to/test.tar /backup/archive/
rsync -avzP /path/to/site/ /backup/archive/; rsync -avzP /path/to/site/ /backup/archive/
umount /backup/archive/
gzip /backup/*.tar

This is how you do what you want right now. But it's better to look in the direction of creating a human copy with diffs through some kind of rdiff-backup or rsnapshot

A
Ali Aliyev, 2013-11-19
@ali_aliev

Try the --exclude or --ignore-failed-read options

K
kenny_opennix, 2013-11-19
@kenny_opennix

Add the list of exclusions to the file and the container says that to exclude nueno from the file.
Also for rsync, you can configure csync between servers, then they will be synchronized almost on the fly.

J
jcmvbkbc, 2013-11-19
@jcmvbkbc

file changed while reading

This is a warning, not an error. The rest of the files should be archived normally.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question