Szukaj na tym blogu

piątek, 24 czerwca 2011

In this post I will explain howto backup your files on Solaris10 without any comercial software e.g. TSM, Symantec BackupExec, etc. This tutorial will guide you how to reach this goal with just a basic tools in SOL10.

Backup can be performed against mission critical file systems and files within IT infrastructure.
It contains two elements :
---------------------------------------
- storage place
- backup software

Storage place for backed up objects can be :
-----------------------------------------------------------------
- magnetic tape device (streamer)
- file server(NFS,SAMBA) with RAID (software/hardware) disks accessed by using NAS network
- hardware disk array accessed by using SAN network (iSCSI, FC)
- cd/dvd disk
- flash drive
- TMS (tape management system)

Backup software :
---------------------------
- TSM (Tivoli Storage Manager)
- Symantec BackupExec
- rsync
- rcp
- dump
- etc

Archiving software :
---------------------------
- tar (only archives)
- jar (compresses + archives)
- compress/uncompress/zcat/gzcat (only archives)
- gzip/gunzip/gzcat (only compresses)
- zip/unzip (compresses + archives)

IMPORTANT !!!
Some mentioned above archiving software products archive files and compress but some do either archiving or compressing.



TAR (tape archive)

Allows to create, extract file from a file archive or any removable media such as tape or diskette.

The tar command archives files to and extracts files from a single file called a tar file. The default device for a tar file is a magnetic tape device.

SYNTAX :
-------------------
tar functions archivefile filenames

Functions for the tar Command

Function

Definition

c


Creates a new tar file.


t


Lists the table of contents of the tar file.


x


Extracts files from the tar file.


f


Specifies the archive file or tape device. The default tape device is /dev/rmt/0. If the name of the archive file is "-", the tar command reads from the standard input when reading from a tar archive or writes to the standard output if creating a tar archive.


v


Executes in verbose mode, writes to the standard output.


h


Follows symbolic links as standard files or directories.

You can use tar to create archive of multiple files and then place this archive file on a tape or record on dvd so other users can share this file.

Usage scenario :
---------------------
1. creating home directory archive on a tape
$ cd
$ mt -f /dev/rmt/0 status
$ tar cvf /dev/rmt/0 .

2. create tar archive with multiple files
$ cd
$ tar cvf files.tar file1 file2 file3

3. viewing an archive from a tape
$ tar tf /dev/rmt/0

4. viewing files i narchive file
$ tar tf files.tar

5. retrieving files from a tape device
$ tar xvf /dev/rmt/0

6. retrieving files from archive file
$ tar xvf files.tar



JAR

Combines multiple files into single archive file and then compress the file. It copies and then compresses files into single archive file.
This tool is standard feature of SOLARIS 10 and is available on any system that uses JVM (java virtual machine).
TOP TIP !
The jar command was created to enable programmers working with JavaTM technology to create a single archive that they could download instead of downloading multiple individual files. Also it allows java programs to run files from within a jar file, without having to extract the files. Also correct use of the manifest allows jar files to be run as a self contained executable program without having to extract the files.

SYNTAX :
-------------------
jar options destination filenames

The table shows the options you can use with the jar command.

Options for the jar Command

Option

Definition

c


Creates a new jar file.

t


Lists the table of contents of a jar file.

x


Extracts the specified files from the jar file.

f


Specifies the jar file to process (for example,/tmp/file.jar). The jar command sends the data to the screen (stdout) if the f option is not used.

v


Executes in verbose mode.
Usage scenarios
-------------------------------
compress and archive files into single archive file
$ ls
dante dir2 dir5 file.2 file3 fruit tutor.vi
dante_1 dir3 file.1 file2 file4 fruit2
dir1 dir4 file1 file.3 files.tar practice


$ jar cvf /tmp/bundle.jar *
added manifest
adding: dante(in = 1319) (out= 744)(deflated 43%)
adding: dante_1(in = 368) (out= 242)(deflated 34%)
adding: dir1/(in = 0) (out= 0)(stored 0%)
adding: dir1/coffees/(in = 0) (out= 0)(stored 0%)
adding: dir1/coffees/beans/(in = 0) (out= 0)(stored 0%)
adding: dir1/coffees/beans/beans(in = 12288) (out= 3161)(deflated 74%)
adding: dir1/coffees/nuts(in = 0) (out= 0)(stored 0%)
adding: dir1/coffees/brands(in = 0) (out= 0)(stored 0%)
adding: dir1/fruit/(in = 0) (out= 0)(stored 0%)
adding: dir1/trees/(in = 0) (out= 0)(stored 0%)
... (output truncated)

IMPORTANT !!!
The jar command does not back up symbolic links as links. The jar command resolves the symbolic link and copies the file's contents.


COMPRESS / UNCOMPRESS / ZCAT / GZCAT

compress command is used for compressing storage space occupied by files. The amount of compression depends on file type, typically compression of text file reduces its size 50-60 %.

SYNTAX :
---------------
compress [-v] file

Usage scenario
1. compress file named dante
$ compress dante

When compression is complete, the compressed file has .Z extension.


2. compress archived tar file
compress -v files.tar
It will substitute files.tar by files.tar.Z file. Dash v is for verbose mode.

3. view compressed file with compress command
$ zcat dante.Z OR $ zcat dante.tar.Z | tar xvf -

4. uncompress file
$ uncompress -v files.tar.Z

5. view compressed file with compress command
uncompress -c files.tar.Z | tar tvf -

6. view compressed file with compress command
gzcat files.tar.Z



GZIP / GUNZIP

gzip command uses Lempel-Ziv (LZ77) algorithm to compress size.

SYNTAX
-----------------
gzip [-v] filenames

Usage scenario
------------------------------
1. compress 4 files
$ gzip file1 file2 file3 file4
$ ls
file1.gz file2.gz file3.gz file4.gz


2. restore gzip file
gunzip file4.gz

3. viewing the content of compressed file
gzcat file4.gz



ZIP / unzip

zip command compresses and archives multiple files into single file.

SYNTAX
-----------------
zip target_filename source_filenames

Usage scenarios
1. compress and archive file into single file
zip files.zip file1 file2

2.view files in archived file
unzip -l files.zip

3. uncompress the contetn of archived file
unzip files.zip
IMPORTANT !!!
Comparing compression programs zip, gzip, compress, jar the most effective compression algorithm is implemented in gzip cmd.



RCP

rcp is remote copy protocol and is not he best way to copy files between two systems.

SYNTAX
---------------------
rcp source_file hostname:destination_file
OR
rcp hostname:source_file destination_file
OR
rcp hostname:source_file hostname:destination_file


Usage scenario
------------------------------
1. copy local file1 to another host
$ rcp file1 host1:/tmp

2. copy remote file file1 to local host
$ rcp host1:/tmp/file1 file1

3. copy recursively directories
rcp -r ~/perms host1:/tmp




RSYNC




DUMP