At some point you may wish to archive some files and/or folders so that you can save these to some sort of longterm storage (e.g. CD-R, another hard drive, etc.). You can use the tar command to create a tar archive (basically a "bundle" of files and folders) and then compress the resulting tar file.
To create this compressed archive, do something like the following:
[student@hostname ~]$ tar -zcf archive.tar.gz filename folder
The c option tells gtar to create the archive. The f option specifies that the filename will be the next argument, and the z option tells gtar to compress (gzip) the tar archive. All other filenames and/or folders specified after the archive name will be added to this compressed archive. So essentially this will create a file named archive.tar.gz containing the file filename and the folder.
There are two types of automatic backups performed on your Linux data: snapshots and tape. Snapshots are an online, read-only copy of your recent data. Tape backups are also performed to add another layer of data protection. The primary differences between the two is that snapshots only provide access to recent changes (within the last week) but you can do your own restores. Tape backups are kept for months, but only the system administrators can restore this data for you.
Our Network File System (NFS) file server, unixspace, provides file system backup called snapshots. A snapshot is an on-line, read-only copy of the entire file system. Snapshots can be accessed by users as read-only files to recover previous versions of files (for example, files that have been accidentally changed or deleted). This feature allows users to restore their own files without the system administrator. To ensure system security, files within a snapshot carry the same permissions as the original files.
There is a “magic” directory named .snapshot which does not normally show up in a directory listing under each user’s home directory. There are also few sub-directories under .snapshot based on the snapshot schedule. The command to view the snapshots with access times is ls -lu (Note: ls -al will not show the correct date information).
[student@hostname ~]$ ls .snapshot 08132003-1200pm 08132003-1200am 08122003-1200am 08092003-1200am 08132003-0800am 08122003-0800pm 08112003-1200am 08082003-1200am 08132003-0400am 08122003-0400pm 08102003-1200am 08072003-1200am
or
[student@hostname ~]$ cd .snapshot [student@hostname ~/.snapshot]$ ls -lu total 2400 drwx--x--x 81 ecst eg 200704 Aug 7 00:00 08072003-1200am drwx--x--x 81 ecst eg 200704 Aug 8 00:00 08082003-1200am drwx--x--x 81 ecst eg 200704 Aug 9 00:00 08092003-1200am drwx--x--x 81 ecst eg 200704 Aug 10 00:00 08102003-1200am drwx--x--x 81 ecst eg 200704 Aug 11 00:00 08112003-1200am drwx--x--x 82 ecst eg 200704 Aug 12 16:00 08122003-0400pm drwx--x--x 82 ecst eg 200704 Aug 12 20:00 08122003-0800pm drwx--x--x 82 ecst eg 200704 Aug 12 00:00 08122003-1200am drwx--x--x 82 ecst eg 200704 Aug 13 04:00 08132003-0400am drwx--x--x 82 ecst eg 200704 Aug 13 08:00 08132003-0800am drwx--x--x 82 ecst eg 200704 Aug 13 00:00 08132003-1200am drwx--x--x 81 ecst eg 200704 Aug 13 12:00 08132003-1200pm
The current snapshot schedule is:
Seven snapshots at midnight for the most recent 7 days
Six snapshots (one every four hours) for the past 24 hours—12:00am, 04:00am, 08:00am, 12:00pm, 04:00pm, 08:00pm
Files in the .snapshot directory are read-only, hence they may only be copied (through cp). Also due to sharing of disk space, it is wise to rename the file name to avoid overwriting the same disk space. The following is the procedure to restore a file named software.info in Files directory:
[ecst@hostname ~/Files]$ pwd /home/accounts/facultystaffstaff/e/ecst/Files [ecst@hostname ~/Files]$ mv software.info soft [ecst@hostname ~/Files]$ cd [ecst@hostname ~]$ cd .snapshot [ecst@hostname ~/.snapshot]$ ls -lu total 2400 drwx--x--x 81 ecst eg 200704 Aug 7 00:00 08072003-1200am drwx--x--x 81 ecst eg 200704 Aug 8 00:00 08082003-1200am drwx--x--x 81 ecst eg 200704 Aug 9 00:00 08092003-1200am drwx--x--x 81 ecst eg 200704 Aug 10 00:00 08102003-1200am drwx--x--x 81 ecst eg 200704 Aug 11 00:00 08112003-1200am drwx--x--x 82 ecst eg 200704 Aug 12 16:00 08122003-0400pm drwx--x--x 82 ecst eg 200704 Aug 12 20:00 08122003-0800pm drwx--x--x 82 ecst eg 200704 Aug 12 00:00 08122003-1200am drwx--x--x 82 ecst eg 200704 Aug 13 04:00 08132003-0400am drwx--x--x 82 ecst eg 200704 Aug 13 08:00 08132003-0800am drwx--x--x 82 ecst eg 200704 Aug 13 00:00 08132003-1200am drwx--x--x 81 ecst eg 200704 Aug 13 12:00 08132003-1200pm [ecst@hostname ~/.snapshot]$ cd 08132003-0400am [ecst@hostname ~/.snapshot/08132003-0400am]$ cd Files [ecst@hostname ~/.snapshot/08132003-0400am/Files]$ pwd /home/accounts/facultystaffstaff/e/ecst/.snapshot/Files [ecst@hostname ~/.snapshot/08132003-0400am/Files]$ cp software.info ~/Files [ecst@hostname ~]$ cd [ecst@hostname ~/Files]$ cd Files [ecst@hostname ~/Files]$ ls -al so* -rw------- 1 ecst staff 2412 Jan 29 11:20 soft -rw------- 1 ecst staff 2412 Jan 29 16:19 software.info
Two types of backups are performed on our Linux data. Daily tape backups are performed each day and are retained for one month. Archival tape backups are performed once a month and are retained for one year. Please contact the system administrators if you need data restored from tape.