Simple Backup Methods Jon Larsen Omaha Linux User Group March 7th, 2006
Simple Backups? Protecting your data is very important. There are several backup methods under Linux/UNIX we can be used to protect your data. We will discuss a few of the simple, common tools.
Utilites Covered in this presentation tar rsync netcat dd unison
tar ● Originally designed for sequential tape devices for backup purposes ● Has been extended to use to use the -f option for files ● Compression capabilities added (-z, -Z and -j) ● Unix Pipes can also be used ● Man tar ●
Backup a directory ● In it's simplest form – tar -czf filename.tar.gz /home/username ● c – create ● z – gzip ● f - filename ● /home/user – 'source'
Alternate ● Using bzip2 – tar -cjP -–preserve -f filename.tar.bz2 /home/username – c – create – j – bzip2 – P – don't strip leading '/' from paths – --preserve – preserve file permissions – f - file
Simple Tape Drive Backup #!/bin/bash DATE=`date '+%Y%m%d'` tar -cv –blocking-factor 64 –label=Home$DATE –tape-length –exclude /proc –totals -f /dev/st0 /
Restore tar ● Restore backup – tar -xjf filename.tar.bz2 – tar -xzf filename.tar.gz – tar --blocking-factor=64 --tape-length xvf /dev/st0 home/username/file
rsync ● rsync is a computer program which synchronizes files and directories from one location to another ● mirroring takes place with only one transmission in each direction ● ssh tunnel ●
rsync example ● rsync -avz –delete -e “ssh -l username” rname /home/username ● Use ssh tunnel for encryption – a - archive – v - verbose – z - compress
netcat ● In computing, netcat is a network utility for reading from and writing to network connections on either TCP or UDP. It is designed in a thin and simple way, which makes it easy to incorporate in larger applications. Because of its versatility, netcat is also called the "TCP/IP Swiss Army knife". ●
Netcat example ● Create a listener ● nc -l -p 8000 | tar -xP –preserve ● Create the sender ● tar czp –preserve / | nc :8000
dd ● dd is a common Unix program whose primary purpose is the low- level copying and conversion of files. ●
dd example ● Backup a hard drive (duplicate) ● dd if=/dev/hda of=/dev/hdb
unison ● Unison is a file synchronization program for Unix (including Linux, Mac OS X, and Solaris) and Windows used for synchronizing files and directories on multiple computers. ●
unison
Advanced Solutions ● Bacula – ● Amanda –
Open Discussion