- Zip folder linux how to#
- Zip folder linux zip file#
- Zip folder linux archive#
- Zip folder linux full#
TIME=`date +%b-%d-%y` # This Command will read the date.įILENAME=backup-admfactory-$ # The filename including the date. Paste the following script and change your details. e.g.Ĭreate the file using vi editor and paste below script. Also it good to add some dynamic value in the name to make sure there is no overwriting of backup files. Now let's add tar command in a bash script to make this backup process automatic.
Zip folder linux archive#
Backup script Step 1 - archive the contentīacking up your files using tar is very simple using the following command: # tar -cvpzf /backup/ /data/directoryĪ real example would be backing up the HTML folder for your website, my case: # tar -cvpzf /backup/ /var/www/html This method I am using to backup the blog.
Zip folder linux how to#
In this article, we have seen how to install zip compression utility, and also several common use cases of file compression.This article presents how to automatically backup files and directory in Linux. Here is an example to compress hidden files in /home/data $ sudo zip -q myfiles.zip /home/data/.* *
If you also want to zip hidden files, use *.* wildcard expression as shown below. In the above case, zip utility will add all files & directories present in the mentioned directory to your archive. Here is an example to compress all files in /home/data folder $ sudo zip -q myfiles.zip /home/data/* If you want to compress all files in directory and not the directory itself, you need to use wildcard patterns as shown below. $ sudo zip -r myfiles.zip /home/data /home/project If you don’t want to view the compression progress, use -q option for quiet mode. The above command will show the compression percent for each file and can be quite big depending on your folder contents. $ sudo zip -r myfiles.zip /home/data /home/projectĪdding : /home/data/file1.txt (stored 0%)Īdding : /home/data/file2.txt (deflated 10%)Īdding : /home/project/file3.txt (deflated 20%) Let us say you want to compress folders /home/data and /home/project then here is the command to do it. If you want to compress all files in directory, you need to mention -r option for recursive compression. zip extension to your zip file, it will automatically add it. It displays the compression percent for each file. $ sudo zip myfiles.zip file1.txt file2.txt file3.txt
Let us say you have to compress 3 files file1.txt, file2.txt and file3.txt in your present working directory, just run the following command to zip them. Now we will look at a few common use cases for your reference. Otherwise use sudo keyword before zip command above.
Zip folder linux zip file#
It is important that you have the permission to create zip file in the target directory.
Zip folder linux full#
If you want to create zip file in another directory, specify full path to zip file. If you only mention zip_file_name then the zip file will be created in your present working directory. In the above command you need to mention the name of your zip archive after zip command, followed by a space-separated list of file names. Here is the syntax to zip one or more files & folders $ zip zip_file_name file(s) Open terminal and run the following command to install zip utility. Here are the steps to zip files & folders in Linux. In this article, we will look at how to zip files & folders in Linux. It allows you to easily compress files & folders to transfer or store. Zip is a lossless compression tool supported by all Linux systems. It also supports zip compression utility, which is commonly used in Windows. Linux offers many compression tools like gzip and tar for this purpose. Often you will need to compress files & folders before sending them to others, or for the purpose of archival.