command line compression?

Computer builds, hardware and software discussion or troubleshooting, including peripherals. Essentially a general place to talk about desktop computers.
Locked
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

command line compression?

Post by Red Squirrel »

Is it possible to compress files (ex: make a folder a black hole archive) via command line? If yes how do I do it, and how do I extract it? My server drive is getting nearly full so I want to start archiving stuff. I'm hoping to be able to make black hole archives as they are 50% the original size which beats mostly all other compression methods but if that's not possible then anything will do. :dance:

Archived topic from Anythingforums, old topic ID:495, old post ID:4360
Honk if you love Jesus, text if you want to meet Him!
megaspaz
Posts: 340
Joined: Wed Dec 18, 2002 10:08 pm

command line compression?

Post by megaspaz »

Red Squirrel wrote: Is it possible to compress files (ex: make a folder a black hole archive) via command line? If yes how do I do it, and how do I extract it?  My server drive is getting nearly full so I want to start archiving stuff.  I'm hoping to be able to make black hole archives as they are 50% the original size which beats mostly all other compression methods but if that's not possible then anything will do.  :dance:
man tar

Archived topic from Anythingforums, old topic ID:495, old post ID:4365
Image
Resistance is futile...

Registered Linux User #321628
Anime/Toon Avatars
Other Cool Forums

"Never hold your farts in. They travel up your spine, into your brain, and that's where you get s**tty ideas from..." - Woyaya - January 10, 2004
wldkos
Posts: 830
Joined: Mon Feb 24, 2003 12:19 pm

command line compression?

Post by wldkos »

a black hole???

+1 on the "man tar"

im sure well get questions on how to use it though, which is fine.

Archived topic from Anythingforums, old topic ID:495, old post ID:4374
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

command line compression?

Post by Red Squirrel »

After second try I got it working but there's like hardly any compression on tars, so is there a different way? Black holes are incredible archives, you can get some folders down to like 10% the original size, depending on what's in it. Usually it's 50% but the few last folders I did locally I turned 1GB of data to like 50 megs lol... all logs and easy to compress files.

Archived topic from Anythingforums, old topic ID:495, old post ID:4377
Honk if you love Jesus, text if you want to meet Him!
megaspaz
Posts: 340
Joined: Wed Dec 18, 2002 10:08 pm

command line compression?

Post by megaspaz »

use the -j or -z options with tar. -j will use the bzip compression and -z will use the gzip compression.

Archived topic from Anythingforums, old topic ID:495, old post ID:4397
Image
Resistance is futile...

Registered Linux User #321628
Anime/Toon Avatars
Other Cool Forums

"Never hold your farts in. They travel up your spine, into your brain, and that's where you get s**tty ideas from..." - Woyaya - January 10, 2004
megaspaz
Posts: 340
Joined: Wed Dec 18, 2002 10:08 pm

command line compression?

Post by megaspaz »

does going from 71.3 MB down to 28.2 MB count as a black hole? :didi:

that's using the gzip compression on my home directory.

Image

Image

Archived topic from Anythingforums, old topic ID:495, old post ID:4398
Image
Resistance is futile...

Registered Linux User #321628
Anime/Toon Avatars
Other Cool Forums

"Never hold your farts in. They travel up your spine, into your brain, and that's where you get s**tty ideas from..." - Woyaya - January 10, 2004
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

command line compression?

Post by Red Squirrel »

Well that's pretty good I'll go with that then.

How to I fix this error though?

[root@localhost day_backup]# tar -cfz local.tar local.old
tar: local.tar: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
[root@localhost day_backup]#


Archived topic from Anythingforums, old topic ID:495, old post ID:4399
Honk if you love Jesus, text if you want to meet Him!
megaspaz
Posts: 340
Joined: Wed Dec 18, 2002 10:08 pm

command line compression?

Post by megaspaz »

the command structure matters when using tar.

tar -cvzf name_of_archive.tar.gz directory_or_files

because the z came in front of the f, you need to put the name of the tarball first before the source directory. it could also be an error in the naming convention in that you gave the -z option so it was expecting the output file to have a *.tar.gz extension.

Archived topic from Anythingforums, old topic ID:495, old post ID:4400
Image
Resistance is futile...

Registered Linux User #321628
Anime/Toon Avatars
Other Cool Forums

"Never hold your farts in. They travel up your spine, into your brain, and that's where you get s**tty ideas from..." - Woyaya - January 10, 2004
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

command line compression?

Post by Red Squirrel »

Thanks that worked... but I only got it down to 54MB and the folder was 64MB is that normal?

Archived topic from Anythingforums, old topic ID:495, old post ID:4405
Honk if you love Jesus, text if you want to meet Him!
megaspaz
Posts: 340
Joined: Wed Dec 18, 2002 10:08 pm

command line compression?

Post by megaspaz »

depends. i think gzip does really good on text files. if you got a lot of binaries, the compression might not be so good. if you want you can seperate out the commands. like do a tar first with no -z option and then use the gzip command.

man gzip

to get the options of gzip.

or you could try it with the -j option and try the bzip compression. iiirc, bzip should do better compression.

man bzip2

Archived topic from Anythingforums, old topic ID:495, old post ID:4406
Image
Resistance is futile...

Registered Linux User #321628
Anime/Toon Avatars
Other Cool Forums

"Never hold your farts in. They travel up your spine, into your brain, and that's where you get s**tty ideas from..." - Woyaya - January 10, 2004
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

command line compression?

Post by Red Squirrel »

It's mostly text file (html and php) there's some binaries such as pictures but most of it is html. I'll try it with other folders though and see what I get. If not I can just set my samba permissions to write and do it with power archiver. gzip is way faster then black hole at compressing though. If I want to black hole my whole backup folder It's something I'd leave on overnight. :D

Archived topic from Anythingforums, old topic ID:495, old post ID:4407
Honk if you love Jesus, text if you want to meet Him!
wldkos
Posts: 830
Joined: Mon Feb 24, 2003 12:19 pm

command line compression?

Post by wldkos »

Tar just makes an archive of the files with no compression. You need to add the -z for gzip compression which is really good. If you use -j in stead of -z you are using the bzip which is even better compression.

I think geekhaven had an article on this.

Archived topic from Anythingforums, old topic ID:495, old post ID:4464
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

command line compression?

Post by Red Squirrel »

Yeah while gzip and tar are good, they don't compete with black hole. :P But it's ok, since it's good to know there's the tar command since I can use this to make quick archives. I have a 30GB folder on my server and I ain't black holing that over the network. :o So I'll gzip that one, much faster.

Archived topic from Anythingforums, old topic ID:495, old post ID:4465
Honk if you love Jesus, text if you want to meet Him!
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

command line compression?

Post by Red Squirrel »

Hmm I just noticed I have backups of backups of backups at some places. while compression is good, nothing beats deletation, when you want to save space. :P

Archived topic from Anythingforums, old topic ID:495, old post ID:4466
Honk if you love Jesus, text if you want to meet Him!
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

command line compression?

Post by Red Squirrel »

hahaha I have an archive going and it's been like 2 hours. :lol: It's a huge folder with tons of files of different type and sizes. :D

Archived topic from Anythingforums, old topic ID:495, old post ID:4469
Honk if you love Jesus, text if you want to meet Him!
Locked