Before we start, make sure zip package is installed in your system, by type zip in your terminal.
zip
if there are no zip package installed, it will reply -bash: zip: command not found
so you must install it first by type :
yum -y install zip
1. Zip
Now you have zip package installed in your system, now type zip, there are a lot of option for zip, we don't use that all, i usually only use -r and -v.
-r is recurse into directories it means, zip include directory
-v is verbose it will showing line by line what file has been added to your zip file
the command fo zip is
zip [options] [new_file_name.zip] [dir / file(s) that we want to zip]
example :
i want to zip files with .txt as extension
zip -v /home/backup/backup_mytext.zip /home/tutorial/*.txt
i want to backup my website file in /html/wordpress into /home/backup/
cd /var/www/html/wordpress/
zip -rv /home/backup/backup_myweb_15062015.zip *
2. Unzip
Before using unzip, try type
unzip
if the reply is -bash: unzip: command not found it mean there are no unzip package in your system, so you must install it first by type
yum -y install unzip
Now unzip package already installed in your system, lets start
To view file in .zip, use this command
unzip -l /home/backup/backup_myweb_15062015.zip
To restore / extract zip file, use this command
unzip /home/backup/backup_myweb_15062015.zip -d /var/www/home/html/wordpress
To restore / extract zip file, and overwrite it
unzip -o /home/backup/backup_myweb_15062015.zip -d /var/www/home/html/wordpress
To restore / extract zip file, and update it
unzip -u /home/backup/backup_myweb_15062015.zip -d /var/www/home/html/wordpress
There are a lot of options to use, but not all of that options is used, it depends on your case, maybe you will use it, but these are a basic command in compress and extract file(s)
0 comments:
Post a Comment