Tag Info

New answers tagged

0

I was thinking that you could use a fuse filesystem or something but then I realized that there is a problem with this in principle and that it is impossible to do. You need tar's output to be streamed out to a remote system with curl, which means that tar must be able to write its output fully sequentially. But the tar file format requires that each member ...


0

You could pipe it to gzip without the option result-file: mysqldump -u user -h host -ppass dbname | gzip -9 > mysqldump.gz


0

Not quite sure that's what you want. To read from a pipe means to read from standard input. This is done using tar xf - (or tar xzf - for compressed streams), where the - indicates standard input. Similarly to write to standard output: tar cf - (or tar czf -).


1

This should work, with some caveats. For one thing, beware of differing FS UUIDs; modern distros often list mounts in /etc/fstab via UUID, which won't survive making new FS and untarring (though it might survive a dd straight from one block device to the other). For another, you'll need to re-tweak GRUB to make it boot, making sure to give the proper set ...


1

Utilizing Joseph R.'s suggestion one can use the regex [^/]$ to grep for the files by looking for lines not ending with /. tar tzf archive.tar.gz | grep -e "[^/]$"


0

Yes; that is exactly how you backup and restore a system.


0

One month late, but I found the most appropriate solution for my case (in a shell script) is to go to the parent directory and execute the command there. cd /var/www/ tar -czf mysite.gz mysite Instead of: tar -czf /var/www/mysite.gz /var/www/mysite


1

The tar command does not zip. Not even with the -z flag. However, it does collect a series of files/folders and optionally compress the result. To contrast, zip compresses each file and adds it to an archive. zip and tar use different compression algorithms. The man page for tar shows the -C flag (--directory) to change directory, so you could do this tar ...


2

You can try following: tar -czf ./zips/someFile.tar.gz -C ./tmp/ someFolder


1

You can use the parameter -C or --directory tar -czf ./zips/someFile.tar.gz -C ./tmp someFolder From man tar -C, --directory DIR change to directory DIR Example % ls -og total 4 -rw-rw-r-- 1 0 Mai 21 18:39 bar drwxrwxr-x 2 4096 Mai 21 18:39 foo tar -cvf ../sample.tar -C /home/user/tmp . tar -tvf ../sample.tar drwxrwxr-x user/user 0 ...


-1

tar -cf foo.tar foo/ | xz -9 foo.tar Generates foo.tar.xz at -9 compression WITHOUT streaming, which yields a smaller file. Streaming in LZMA inflates the file by a few bytes.


1

First install XZ yum -y install xz then tar -xvf yourfile.tar.xz


1

Should work with the following command: tar -xvfz linux-2.6.32.65.tar.xz


-1

tar does not have an integrity check. Example: $ echo JJJJJJJJJJJJJJJJJJ > b $ tar cvf a.tar b $ sed -i s/JJJJJJJJJJJJJJJJJJ/tttttttttttttttttt/g a.tar $ tar xvf a.tar $ cat b tttttttttttttttttt See, the content of a.tar archive changed, so the file b has completely different content, but tar did not notice this. This is true for any tar, including ...


3

Your --directory suggests you're using either GNU or modern BSD tar. With GNU tar: tar --directory=/Users/joe/images --transform='s|[^/]*|common|' \ -czvf images.tgz dir1/image1.jpg dir2/image2.jpg With BSD tar: tar --directory=/Users/joe/images -s'|[^/]*|common|' \ -czvf images.tgz dir1/image1.jpg dir2/image2.jpg The idea being the same: replace ...


1

In principle, yes. But you forgot to specify the actual files or directories to add to the tar archive. Note also that if /home/backup is a directory you should use the test option -d. If OTOH you want to check whether there are files in the directory /home/backup you'd need an adjustment; to enter the files in that directory into the tar archive, this may ...


2

To make a copy of a filesystem as you want you have to be root. In addition you need a "clean version". As such you want to use a bind mount of your root so you get the entire filesystem as is. You may even be able to bind mount read only if you're worried about tar.


2

To confirm I follow you, there's the following items at play: An installation script (for the various tools in the tarball) A tarball with various tools packaged inside it (as shell scripts, some of which may not work with the parent OS) I'll assume you are admin on the machine you are uploading to. I think the right thing to do would be to put the ...


1

It seems like copy parameter for unarchive module is what tripped you up. http://docs.ansible.com/unarchive_module.html states: -If copy=yes (default), local path to archive file to copy to the target server; can be absolute or relative. -If copy=no, path on the target server to existing archive file to unpack. In essence get_url downloaded your file to ...


0

Look at rsnapshot. I'm pretty sure it will do everything you want, and as a bonus can be expanded to keep files for longer than two months when you get a bigger drive.


0

You can of course read the source of tar to check for yourself. Simply put, tar does no interpretation of the byte sequence that make up a filename. Just like the kernel, it treats it as an abstract sequence of bytes. So it is 'safe', in the sense that usable files will be extracted. In the environment where the files are unpacked, then user tools may ...


0

Solution found: was a corrupted file on their server,md5 refer good because is referred to the corrupted file I download an older release which works fine


4

The steps highlighted at https://support.pivotal.io/hc/en-us/articles/202392488-gpdbrestore-gp-restore-fails-with-gzip-stdin-invalid-compressed-data-format-violated- fixed it for me: wget http://www.gzip.org/fixgz.zip unzip fixgz.zip gcc -o fixgz fixgz.c fixgz <corrupted_gzip_backup_file>.gz <fixed_gzip_backup_file>.gz This is weird, given ...


1

In complement to @apaul, I emphasize that compressing files individually bzip2 *.log.* (replace bzip2 by gzip, xz, or what ever your favorite file zip is) may be important: This way you can still see (bzcat file.bz2), search (bzgrep file.bz2), edit (vi file.bz2) the compressed file and remove the older ones when necessary.


5

I figured out a tar solution by myself. It deletes single file after compressed it into the target file. The compressing speed is not quite fast, though. The command looks like: tar -zcvf my_log.tar.gz *.log --remove-files


9

gzip or bzip2 will compress the file and remove the non-compressed one automatically (this is their default behaviour). However, keep in mind that while the compressing process, both files will exists. If you want to compress log files (ie: files containing text), you may prefer bzip2, since it has a better ratio for text files. bzip2 -9 myfile # ...


0

-C is not a portable option anyway. It's a GNU option not a Unix one. tar is no longer specified by the Single Unix Specification anyway as there's so much difference between the implementations. It has pax to create archives portably. You could do: pax -ws'|.*//||' /backupmnt/statusService//. /some/other/dir//./*.ext | xz > file.tar.xz (xz/gzip ...


1

You can do this with pax(1), which is the posix successor to tar, but it never really caught on. It can write tar files and it can do the filename transformation you want to do: pax -wzf archive -s '|directory/\?||' directory That breaks down to: -w write an archive (same as -c for tar) -z compress archive (same as tar) -f archive write to file archive ...


2

try tar cvf archive.tar -C somedir $(ls somedir) where cvf will Create Verbose(ly) File Archive.tar -C somedir will instruct tar to use somedir $(ls somedir ) list file in somedir and $( ) passe result as argument Edit: As pointed in comment, use ls -A (not ls -a) to list dotfile.


5

Use -C: tar czf archive -C directory . This instructs tar to use directory as its working directory, and archive everything contained in the directory (.). Using -C is nearly equivalent to using cd; archive above is interpreted relative to the current directory when tar starts, then tar changes its working directory to directory before interpreting .. ...


0

This is not an exact answer to your question but you could use one command instead of two: 7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on archive.7z dir1 adds all files from directory "dir1" to archive archive.7z using "ultras ettings" other formats supported are: zip, gzip, bzip2 or tar. for this just replace 7z after -t. --source man 7z NOTE: don't ...


2

Why do not use explicit directory change? cd /backupmnt/statusService && tar -czf /backupmnt/abc.tar.gz * Or you can use relative paths: cd / tar -czf /backupmnt/abc.tar.gz backupmnt/statusService1/* backupmnt/statusService2/* backupmnt/statusService3/* Which can be even better solution as you will keep files separated in folders and avoid ...


6

* is expanded by the shell before tar gets executed. So, making tar change the directory invalidates the arguments that * expanded into. You can simply tell tar to compress the directory instead: tar -czf /backupmnt/abc.tar.gz -C /backupmnt/statusService/ . The . represents the current directory, which will change when tar changes directories. This will ...


2

I found two solutions: With GNU tar, using the awesome -I option: tar -I pigz -xvf /path/to/archive.tar.gz -C /where/to/unpack/it/ With a lot of a Linux piping (for those who prefer a more geeky look): unpigz < /path/to/archive.tar.gz | tar -xvC /where/to/unpack/it/ More portably (to other tar implementations): unpigz < /path/to/archive.tar.gz | ...



Top 50 recent answers are included