Is this possible? Create a tar.gz of a directory and place it in a different directory without all of the directories nested in the path?
Lemme explain. I wanna back up webroot located at /var/www/html/webroot by creating a file called webroot.tar.gz but I wanna place it in /var/www/html/archive, in the archive itself I only want to see the webroot directory, and it's files contained with in. I do not want to open the archive and see var, then www, then html, then webroot. I have a feeling I need to be using the -C option but I can't for the life of me figure out how.
Any tips? I am hoping to do this in a single command. Update: I figured it out! Thanks for reading anyhow. Code:
tar -czf /var/www/html/archive/webroot.tar.gz -C /var/www/html/ webroot |
-C changes the start directory.
You can achieve the same with Code:
( cd /var/www/html && tar -czf /var/www/html/archive/webroot.tar.gz webroot ) |
you must not put the tar created into the source directory tree (conflict between -C <dir> and -f <file>). Or at least do it in two steps: first create that tar somewhere outside and finally move it to the final location. (post #2 is ok, because webroot is packed into archive).
|
Good point in principle,
but here the webroot aka /var/www/html/webroot is outside. |
Quote:
Thanks for the explanations all! |
All times are GMT -5. The time now is 02:40 AM. |