recursive archive directories and subdirectories

Hi everyone,

Maybe this is simple question for many of you, but I get confused.:confused:

How to archive a parent directory which contains some subdirectories and some files?
I have searched this forum, there are some commands like tar,etc, I tried but can not be implemented in my system.
My system: IBM AIX 5.3

Many thanks for all your response.:wink:

Why can't you use tar? That's a basic tool found on every UNIX system I know.

This will create a compressed tar archive, containing all files and subdirectories. Replace 'compress' by 'gzip' or 'bzip2' if available, as they provide a much better compression.

$ tar -cf - /path/to/directory/ | compress -c > backup.tar.Z

Hi pludi,

Thanks for the guide. But still not solved my problem. Maybe this will make my question easier to understand.

root@xxx # pwd
/tmp/wilson
root@xxx # ls -l
total 8
drwxr-xr-x 2 root system 256 Jan 12 15:50 ibmType
drwxr-x--- 5 root system 256 Mar 27 15:47 rmvcsub
drwxr-xr-x 10 root system 4096 Mar 27 18:46 study
drwxr-xr-x 8 root system 256 Mar 13 19:40 study1
root@xxx # uname -a
AIX xxx 3 5 xxxxxxx

So, how to archive study and study1 directories into 1 file, and the archive result will be in current directory?

Thanks again for the help. :slight_smile:

# pwd
/tmp/wilson
# tar -cvf - study study1 | compress -c > study.tar.Z

or, if you want the complete path

# cd /
# tar -cvf - /tmp/wilson/study /tmp/wilson/study1 | compress -c > /tmp/wilson/study.tar.Z
1 Like

Hi Pludi,

I have tried your command. It worked!

Do you have any tar related document which can be easily understand?
Will be very appreciate if you can recommend to me :slight_smile:

Many thanks.

Besides "man tar"? Only the documentation for GNU tar, which probably works a bit different than the AIX variant, and the Wiki page. But the key behavior is defined by the POSIX standard, those should work the same across the board.

1 Like

nice docs brother pludi. thks