Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Backups, Commands & Shells

Copying directories using tar and rsync

Submitted by on November 19, 2005 – 11:20 pm One Comment

In this example we use the tar command to copy the contents of the /export/home directory to /temphome. This particular syntax forgoes the creation of an actual tarball file. This can be useful if you are short on disk space.

cd /export/home
tar cf - * | (cd /temphome; tar xf -)

Note there is a space before and after the hyphen.

An alternative to this method is to use rsync. The appropriate rsync syntax would be as follows:

rsync -avu /export/home/ /temphome/

You can also use rsync to update the contents of /temphome to match the contents of /export/home. This will copy files from /export/home that are not in /temphome and will delete file from /temphome that are not in /export/home:

rsync -avu --delete /export/home/ /temphome/
Print Friendly, PDF & Email

One Comment »

Leave a Reply

%d bloggers like this: