0% found this document useful (0 votes)
13 views4 pages

Practice 2B - Backup and Restore On Linux

The document provides an overview of the tar program used for creating and manipulating tar archives, which are single files containing multiple files and their metadata. It explains key concepts such as extraction, archiving, and the various options available for using tar, including commands for creating, extracting, and listing archive contents. Additionally, it includes exercises for practicing file backup and restoration using tar commands.

Uploaded by

jesus perez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views4 pages

Practice 2B - Backup and Restore On Linux

The document provides an overview of the tar program used for creating and manipulating tar archives, which are single files containing multiple files and their metadata. It explains key concepts such as extraction, archiving, and the various options available for using tar, including commands for creating, extracting, and listing archive contents. Additionally, it includes exercises for practicing file backup and restoration using tar commands.

Uploaded by

jesus perez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Computing Systems

PRACTICE 7:
File Backup (tar/gzip)
The tar program is used to create and manipulate tar archives. An archive is a single
file which contains the contents of many files, while still identifying the names of the
files, their owner(s), and so forth. (In addition, archives record access permissions, user
and group, size in bytes, and data modification time. Some archives also record the file
names in each archived directory, as well as other file and directory information.) You
can use tar to create a new archive in a specified directory.

The files inside an archive are called members. We use the term file to refer only to files
accessible in the normal ways (by ls, cat, and so forth), and the term member to refer
only to the members of an archive. Similarly, a file name is the name of a file, as it
resides in the file system, and a member name is the name of an archive member within
the archive.

The term extraction refers to the process of copying an archive member (or multiple
members) into a file in the file system. Extracting all the members of an archive is often
called extracting the archive. The term unpack can also be used to refer to the extraction
of many or all the members of an archive. Extracting an archive does not destroy the
archive's structure, just as creating an archive does not destroy the copies of the files
that exist outside of the archive. You may also list the members in a given archive (this
is often thought of as "printing" them to the standard output, or the command line), or
append members to a pre-existing archive. All of these operations can be performed
using tar.

Because the archive created by tar is capable of preserving file information and directory
structure, tar is commonly used for performing full and incremental backups of disks. A
backup puts a collection of files (possibly pertaining to many users and projects) together
on a disk or a tape. This guards against accidental destruction of the information in those
files. GNU tar has special features that allow it to be used to make incremental and full
dumps of all the files in a file system.

The table below shows the most common tar options; some of them are not available in
all versions of tar, so check the manual page before using it. If the tar implementation that
exists in our system does not fit our needs, we can always use the GNU version
(http://www.gnu.org/), perhaps the most complete nowadays.

Opción Acción realizada


c create a archive file.
x extract a archive file.
t viewing content of archive file.
r append files to the end of an archive

I. E. S “Zaidín-Vergeles” 1º SIA
Computing Systems

v show the progress of archive file.


u only append files that are newer than the existing in archive
f filename of archive file.
Z filter archive through compress/uncompress
z filter archive through gzip.
j filter archive through bzip2.
(newer) Only store files newer than DATE. Example: -N 2015-02-01 or
N
–N 01-feb-15
g create/list/extract new GNU-format incremental backup

Explains which actions perform the following commands:

• date +%d%b%y – Shows Day Month(Short) Year(Short) (17feb25)

• date –s “2015-02-25” (comillas dobles normales) – Sets date to 25-02-2015

• tar cfzv /tmp/copia`date +%d%b%y`.tar.gz /etc – Creates a compressed copy


of /etc in /tmp/copia(date).tar.gz ex: /tmp/copia17feb25.tar.gz

• tar cfzv /tmp/copia.tar.gz /etc -N 01`date +%b%y` - Creates a compressed


copy of /etc in /tmp/copia.tar.gz of files newer than 01MonthYear ex:
newer than 01feb25

• tar xfz copia.tar.gz – Extracts files of copia.tar.gz

• tar xfz copia.tar.gz etc/passwd - Extracts etc/passwd of copia.tar.gz

• tar rf copia.tar /var (copia.tar debe existir, no funciona con compresión) – Adds
/var to copia.tar

• tar tfz copia.tar.gz – Lists contents of file copia.tar.gz

• tar cfzv /backup.tgz --exclude=/proc --exclude=/backup.tgz --exclude=/mnt


--exclude=/sys --exclude=/tmp / - Creates backup.tgz of / excluding
/mnt,/sys/proc,/backup.tgz,/mnt,/sys and /tmp

I. E. S “Zaidín-Vergeles” 1º SIA
Computing Systems

Exercises:

1. Go to the /tmp directory and make a full copy of the /home directory of
your virtual machine.

2. List the contents of the copy of the previous section.

3. Create some new files within the /home directory (Change the modified
and access date and set it to 01-01-2035)

4. Make a differential copy where the files /directories not included in the
total copy of section 1 are included.

5. Delete the /home directory and restore it by using backups.

6. Create a full copy of the /home directory with the necessary options (-g
file) for future incremental copies.

I. E. S “Zaidín-Vergeles” 1º SIA
Computing Systems

7. Create new files in the /home directory.

8. Creates an incremental copy of the /home directory reflecting the changes.


Check (tar tfz) that only new files have been included.

9. Delete the /home directory and restore it by using the backups.

I. E. S “Zaidín-Vergeles” 1º SIA

You might also like