6
I'm trying to tar my website files that are on my test server to be able to upload them to 'real' server.
tar -cf mysite.tar /var/www
It creates archive fine... but when I open that archive it has var directory, which contains www directory... How do I create archive that has /var/www content in its root, not in subfolders like it's right now?
1Keep in mind that globbing like this will not get file's which name begins with a dot. – John T – 2010-02-01T05:34:49.703
How do I get 'dot' files included too? – None – 2010-02-01T05:55:20.093
Im not good enough with regular expression to figure this one out. I tried something like
but that backs up only the hidden files. – Justin S – 2010-02-01T07:17:55.940
@mea, do you want to preserve the directory structure inside the
/var/www
folder? – John T – 2010-02-02T17:48:57.633@mea. John T got it right. You're asking for trouble when using
– Jonik – 2010-02-14T00:40:33.933*
with tar. Often it may not matter, but when it does, you probably won't even notice the missing "dot" files (and directories!) until much later. Consider accepting this instead: http://superuser.com/questions/103170/tar-a-directory/103177#103177Use "." instead of "*". That gets the entire content of the current directory – mpez0 – 2010-02-14T01:48:00.660
Also, you can put the cd together with the tar: {cd /var/www; tar -cvf backup.tar .} – mpez0 – 2010-02-14T01:48:47.413