If you have a directory named 'data' within the current working directory, use:
- Code: Select all
tar -cvzf data.tar.gz data/
The tar options in use are as follows:
-c : create an archive
-v : verbose - print filenames as they are done
-z : zip - compress the archive
-f : the filename of the resulting archive, which in this case will be data.tar.gz. The 'tar' extension indicates that it's a 'tar' archive, and the 'gz' indicates that it's compressed.
To restore an archive, go to the directory where you want the data to be restored to, and use:
- Code: Select all
tar -xvzf data.tar.gz newdata/
The data will be extracted (the -x option) into the specified directory. Be careful to make sure you don't overwrite any data that is already in that directory - be careful when using powerful commands such as this!
