Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
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.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I create a tarred file then compressed with bzip with following command line;
# tar -jcpf AAA.bz2 /home/path/to/dirA
dirA is about 2G in size.
After working several days on dirA I want to create a new compressed tarred file. Instead of repeating the above command, is there a way starting from the old file AAA.bz2 making use of the options -u, -N, -G, etc. to reduce the compressing time? I looked around on man tar and Internet and could not sort out their combination on the command line.
The tst part is a leftover from my testing, that should be /home/path/to/dirA in your example. Sorry about that
I did use your example as a start, more elegant (and maybe clearer) would be:
tar -jcpf AAA.tar.bz2 /home/path/to/dirA to archive and comress the file (first instance). The only difference between your original command and this one is the name of the compressed archive (AAA.bz2 vs AAA.tar.bz2).
to update:
bunzip2 AAA.tar.bz2 ; tar -upf AAA.tar /home/path/to/dirA ; bzip2 AAA.tar
The first command uses the -j option to compress (using bzip2) the archive.
The second command uncompresses, using bunzip2, the compressed tarball (which leaves you with AAA.tar), after that the tarball is updated using the -u option and compressed again using bzip2.
Tar and/or bzip2 do not delete the original files/dirs that are archived. bzip2 will remove the archive (AAA.tar) and replace this with the compressed archive (AAA.tar.bz2).
Tested the command line, but still having some problem. Steps performed as follows;
1) untar the old-compressed tarball
$ tar -jxpf AAA.bz2
$ ls
AAA.bz2 old-dirA
2) deleted the old-compressed tarball
$ rm AAA.bz2
3) created a new old-compressed tarball again and removed old-dirA
$ tar -jcpf AAA.tar.bz2 old-dirA/
# rm -rf old-dirA
4) ran the command line recommended
$ bunzip2 AAA.tar.bz2 ; tar -upf AAA.tar /home/path/to/new-dirA ; bzip2 AAA.tar
5)
$ ls
AAA.tar.bz2
6) untar the new-compressed tarball
$ tar -jxpf AAA.tar.bz2
It was found that the old-dirA and the new-dirA co-existing. I don't need to retain the old-dirA in the new-compressed tarball.
Furthermore can I create a new-compressed tarball in another name.
e.g. old-compressed tarball=AAA_20060614.tar.bz2 (old date indicated)
new-compressed tarball=AAA_20060624.tar.bz2 (new date indicated)
To my knowledge you cannot remove files from an archive that are no longer present (using tar options), the -u option adds/updates files, it does not remove files from the archive.
This, together with your second question (different names for each [compressed]archive), leads me to believe that you should archive the directory in question completely. It's 'only' 2 Gb.
It's up to you to decide what works better:
1) multiple compressed archives (which could lead to a situation that you need some files from one archive and some from another archive)
2) one archive. All files together in one compressed archive.
I think "tar" will not be the right tool for my application.
Acturally my need is not complicate:-
1) Just backup the working data files in a directory on /home.
2) The compressed files can be restored to another HD on another PC, not only on the original PC.
3) The compressed files can be read without restore
4) In order to reduce the time in creating another backup, the second backup will base on the original compressed files.
Have you had any suggestion? Can folks on the forum shed me some light? TIA
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.