Fastest backup for large files

backupmirrorrsynctar

what is the fastest way to duplicate a folder contain few files with few hundred megs size and other few megs small files? (say, /var/lib/mysql)
cp or tar or rsync or…??

Best Answer

rsync in general will be faster than cp or tar, because rsync only transfers those files which have changed, and with --partial it will only transfer the parts of a file that changed.

Having said that, rsync works much better if you know what you're backupping and can arrange things so that rsync doesn't have to do as much work. For example, rotated log files in /var/log work much better if you rotate them to a filename with a date in it, instead of .0, .1, .2, etc..

One more note: In your question you mention /var/lib/mysql. Using rsync to backup that is a pretty bad idea, use mysqldump to get a reliable backup. If that backup is too large to transfer frequently, use mysql replication and backup from a slave. (You still should do a full backup on the master periodically though, replication can fail too).