Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
tar = Stands for "tape archive" This is a legacy-name for when mag tape was king of backup.
c = 'create' (as opposed to extract)
v = 'verbose'. You can miss this out but it won't tell you which files are being worked on.
f = means specify a file to use as the device. Remember, everything in linux is a 'file' so
the beauty of linux (and unix) is that what works with a specical file like a tape device
will also work for any file - including an entry in a block-special filesystem or a the special
file stdout which is used next in this case.
- = 'stdout' This is the default output for all programs. It is usually - but not allways the
screen. Typically, stdout is 'piped' to another program for further processing.
. = 'current directory'. Therefore this whole comman is context dependent. You must have done a cd
into the desired directory before executing it.
| = 'redirect stdout' to 'stdin' of the following program.
() = create a new shell. Thus the stdin of the tar command is fed to a new shell. Inside this shell,
you can do a whole load of commands.
cd /root/ = 'change directory (inside this subshell only) to a new place - this is the destination
of the backup)
; = 'end of this line - what follows is a new command as if you pressed RETURN first.'
tar xvf - = 'rn tar again' but this time x means eXtract. 'f' has the same meansing, but this time '-'
I like setting up no password handshaking between servers, such as for a migration, then run the following from any directory. Most of the time I will set up the script to run after hours in cron for each directory I want to move:
tar cf - . | ssh <servername> "cd /path-to-dir; tar xf -"