Questions tagged [tar]

GNU tar creates and manipulates archives which are actually collections of many other files; the program provides users with an organized and systematic method for controlling a large amount of data.

GNU tar creates and manipulates archives which are actually collections of many other files; the program provides users with an organized and systematic method for controlling a large amount of data. The name “tar” originally came from the phrase “Tape ARchive”, but archives need not (and these days, typically do not) reside on tapes.

340 questions
153
votes
2 answers

tar - Remove leading directory components on extraction

How can you extract only the target dir and not the complete dir tree? compress tar cf /var/www_bak/site.tar /var/www/site extract tar xf /var/www/site.tar -C /tmp This will produce: /tmp/var/www/site How is it possible to avoid the whole dir…
clarkk
  • 1,875
  • 7
  • 22
  • 31
98
votes
9 answers

mysqldump to a tar.gz

Usually after dumping a MySQL database with mysqldump command I immediately tar/gzip the resultant file. I'm looking for a way to do this in one command: So from this: mysqldump dbname -u root -p > dbname.sql tar czvf dbname.sql.tgz dbname.sql rm…
pygorex1
  • 1,151
  • 1
  • 9
  • 10
72
votes
8 answers

Quickest way to transfer 55GB of images to new server

I currently have two CentOS servers. I need to know how and what the quickest way would be to "tar" up the images directory and SCP it over? Is that the quickest way that I just suggested, because tarring is taking forever... I ran the command: tar…
Andrew Fashion
  • 1,635
  • 7
  • 22
  • 26
58
votes
3 answers

Fastest way to extract tar.gz

Is there anyway to extract a tar.gz file faster than tar -zxvf filenamehere? We have large files, and trying to optimize the operation.
Justin
  • 5,008
  • 19
  • 58
  • 82
43
votes
1 answer

Why does `tar -xvfz` fail, but `tar xvfz` work?

tar -xvfz foo.tar.gz returns an error tar: z: Cannot open: No such file or directory This is completely understandable - the f switch expects a filename, and so needs to be last. However, omitting the hyphen tar xvfz foot.tar.gz works and…
anu
  • 544
  • 1
  • 5
  • 10
35
votes
7 answers

Determine if file is in the process of being written upon?

I need to deploy an automated process (via 1 min cron script) that looks for tar files in a specific directory. If a tar file is found, it is untarred to the appropriate location and then the tar file is deleted. The tar files are automatically…
Jake Wilson
  • 8,494
  • 29
  • 94
  • 121
34
votes
3 answers

Compress every file in a directory into its own compressed file

How do I compress every file in a directory into its own tar whilst preserving the name for each file? i.e. file1.out file2.out --> file1.out.tar.gz file2.out.tar.gz
DD.
  • 3,024
  • 10
  • 34
  • 50
31
votes
8 answers

Is there a smarter tar or cpio out there for efficiently retrieving a file stored in the archive?

I am using tar to archive a group of very large (multi-GB) bz2 files. If I use tar -tf file.tar to list the files within the archive, this takes a very long time to complete (~10-15 minutes). Likewise, cpio -t < file.cpio takes just as long to…
Alex Reynolds
  • 453
  • 2
  • 9
  • 20
30
votes
5 answers

tar: How to create a tar file with arbitrary leading directories w/o 'cd'ing to parent dir

Say I have a directory of files at /home/user1/dir1 and I want to create a tar with only "dir1" as the leading directory: /dir1/file1 /dir1/file2 I know I can first cd to the directory cd /home/user1/ tar czvf dir1.tar.gz dir1 But when writing…
Yan
  • 453
  • 1
  • 4
  • 6
22
votes
4 answers

Does tar preserve permissions if user IDs change?

I need to backup some data with the "p" option on tar command. The problem is the place I'm going to restore this data will have all the same users, but those users may have different IDs. Does that make any difference to tar or will it restore…
Marius
  • 365
  • 1
  • 2
  • 9
20
votes
2 answers

tar: kill the error message: 'tar: Removing leading `/' from member names'

I run this from a cronjob: tar -czvf /var/backups/svn.tgz /var/svn/* That generates this on stderr: tar: Removing leading `/' from member names I would like to avoid this because it is not a real error (for me!). I want on stderr only things that…
Dan
  • 359
  • 1
  • 4
  • 16
19
votes
3 answers

Linux gzip multiple subdirectories into separate archives?

How would I be able to compress subdirectories into separate archives? Example: directory subdir1 subdir2 Should create subdir1(.tar).gz and subdir2(.tar).gz
aardbol
  • 1,463
  • 4
  • 17
  • 25
19
votes
3 answers

How to perform a secure rsync between servers across an unsecured network

Basically what I'm asking is, has anyone come across a means by which to wrap rsync inside ssh. With OpenSSH v4.9+ sftp has some nice options that allow you to chroot the incoming connection and such - and that's a solution that I would look at,…
Xerxes
  • 4,133
  • 3
  • 26
  • 33
18
votes
4 answers

Different md5sums for same tar contents

I run a test creating two tars from the same dir (its files remained unchanged), and I found that their md5sums were different. I assume there's some timestamp being included in the tar's header, but I haven't found the way to override it. My OS is…
xain
  • 657
  • 3
  • 12
  • 24
17
votes
3 answers

How to list content from a tar file without recursion?

I've a tar (gz, bzip) file and want to see its content, but not recursively. This is: The "first level" in the file. I already know how to see content: tar -ztf file.tar.gz But it's recursive!! Thanks!
santiago.basulto
  • 598
  • 2
  • 8
  • 16
1
2 3
22 23