Practice 2B - Backup and Restore On Linux
Practice 2B - Backup and Restore On Linux
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.
I. E. S “Zaidín-Vergeles” 1º SIA
Computing Systems
• tar rf copia.tar /var (copia.tar debe existir, no funciona con compresión) – Adds
/var to copia.tar
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.
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.
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
I. E. S “Zaidín-Vergeles” 1º SIA