New Perspectives On Web Design

(C. Jardin) #1

CHAPTER 8 How to Fix The Web: Obscure Back-End Techniques and Terminal Secrets


baCK uP anD ReSToRe
The tar and zip commands can be used to back up and restore. If your
website is missing, then restoring won’t help you much unless you have
previously backed up. So go back in time and back up your data with one of
the commands below. To go back a whole day:

$ gobackintime 86400
It is now Sat May 10 20:30:57 BST 2013

Just kidding — but it would be nice! The tar command stands for tape
archive and comes from the days when data was backed up on magnetic
tapes. To create an archive of a directory, pass the cfz options to tar which
will create a new archive in a file and then zip it in the gzip format.

$ tar cfz backupfile.tgz /var/www/vhosts/smashingmagazine.com/httpdocs
tar: Removing leading `/' from member names

All Mac and Linux computers support the tar command and most also
have zip. To do the same with zip:
$ zip -r backupfile.zip /directory/to/backup

To see what an archive contains, run:
tar tfz backupfile.tgz
var/www/vhosts/smashingmagazine.com/httpdocs/
var/www/vhosts/smashingmagazine.com/httpdocs/.htaccess...

Or for zip format:
unzip -l backupfile.zip
Archive: test.zip
Length Date Time Name
--------- ---------- ----- ----
0 2012-05-28 00:33 var/www/vhosts/smashingmagazine.com/httpdocs
234 2012-05-28 00:33 var/www/vhosts/smashingmagazine.com/httpdocs/.htaccess
Free download pdf