Note the files/folders excluded are relatively to the root of your tar (I have tried full path here relative to / but I can not make that work). Tar -czvf mysite -exclude='file3' -exclude='folder3' So, my command would look like this cd /home/ftp/ Where the c = create, z = zip, and v = verbose (you can see the files as they are entered, usefull to make sure none of the files you exclude are being added). So, you want to make a tar file that contain everyting inside /home/ftp/mysite (to move the site to a new server), but file3 is just junk, and everything in folder3 is also not needed, so we will skip those two. With following file/folders /home/ftp/mysite/file1 If you have the following structure /home/ftp/mysite/ Old question with many answers, but I found that none were quite clear enough for me, so I would like to add my try. Tar -exclude='./folder' -exclude='./upload/folder2' -zcvf /backup/filename.tgz. ![]() Full command (cd first, so backup is relative to that directory): cd /folder_to_backup The big gotcha is that the -exclude='./folder' MUST be at the beginning of the tar command. ![]() I'm beginning to think the only solution is to create a file with a list of files/folders to be excluded, then use rsync with -exclude-from=file to copy all the files to a tmp directory, and then use tar to archive that directory.Ĭan anybody think of a better/more efficient solution?ĮDIT: Charles Ma's solution works well. I could also use the find command to create a list of files and exclude the ones I don't want to archive and pass the list to tar, but that only works with for a small amount of files. ![]() The tar -exclude=PATTERN command matches the given pattern and excludes those files, but I need specific files & folders to be ignored (full file path), otherwise valid files might be excluded. I have a directory that need to be archived with a sub directory that has a number of very large files I do not need to backup. Is there a simple shell command/script that supports excluding certain files/folders from being archived?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |