About Me

Josh Lyon

Name: Joshua Lyon
Birthday: August 8, 1985
Location: Grapevine, TX
E-mail: josh@boshdirect.com

Home View Blog Technology Backup site (files) from Shell
Backup site (files) from Shell
Written by Josh Lyon   
Friday, 25 January 2008 07:42

Here's a quick code snippet on how to backup files and restore them from the shell.

To back them up, run the following code:

$ tar -zcvf filename.tar.gz folder/

To backup all files in the directory you are currently in, run:
$ tar -zcvf filename.tar.gz .

Here's a breakout of the parameters:
z - gzip compression
c - compress the files
v - verbose output (lists the files)
f - file

To uncompress the file(s) (eg. unload to server - overwriting files), use the following:
$ tar -zxvf filename.tar.gz

The key difference is the c in the compress command above was replaced with an x for the extract command.

 

Comments (0)add comment

Write comment

busy