LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 07-22-2010, 08:13 AM   #1
AKD1
LQ Newbie
 
Registered: Jul 2010
Posts: 1

Rep: Reputation: 0
How do I exclude sub directories from ZIP CLI?


I'm trying to create backup/archive my Ubuntu 10.04 system files (so I can restore it in case my system get corrupted). More specifically, I'm trying to zip the important files in my root directory not including my home directory (which includes my documents which I backup separately/more frequently) to an external hard drive attached via USB (called 'My Book').

Since File Roller didn't give me quite the level of control I was looking for, I created a script that I could execute to backup and archive regularly. Here's a snippet:


cd /media/"My Book"/"Linux Backups"
NOW=$(date +"%b-%d-%y")
LOGFILE=Backup_DellLatitudeD620_Ubuntu_FileSystem-$NOW.log


sudo zip -r -T -v Backup_Root_FileSystem-$NOW / -x /media/'My Book'\* /media\* /proc\* /sys\* /mnt\* /dev\* /cdrom\* /home\* /'lost+found'\* | tee -a $LOGFILE

echo "Checking validity/accuracy of zip file" | tee -a $LOGFILE
unzip -tq Backup_DellLatitudeD620_Ubuntu_FileSystem-$NOW.zip | tee -a $LOGFILE


When I execute this, only the log file is created and no zip file is created. The terminal window shows that it starts to add files, but from the excluded directories, starting with "My Book".

Here is the output from the terminal window:

zip warning: name not matched: /media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/.ecryptfs/amit/.Private/ECRYPTFS_FNEK_ENCRYPTED.FWaYzpV4BZNwE-Qh48zmJMclYKU5FCiPjGrmOaTTyDAaI9Fntyc9NqKorE--/ECRYPTFS_FNEK_ENCRYPTED.FWaYzpV4BZNwE-Qh48zmJMclYKU5FCiPjGrmyhIsd61dTNeTv55Pf0BKdU--/ECRYPTFS_FNEK_ENCRYPTED.FXaYzpV4BZNwE-Qh48zmJMclYKU5FCiPjGrmzvWat6NI8.-y6RjyyN2B4oY-BjxoZQEpY3FjgechqqM-
.. zip warning: name not matched: /media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/amit/.wine/dosdevices/z:/media/My Book/.Trash-1000/files/Backup 2/home/.ecryptfs/amit/.Private/ECRYPTFS_FNEK_ENCRYPTED.FWaYzpV4BZNwE-Qh48zmJMclYKU5FCiPjGrmvAsAMnV1l-zVIrsM5pdJc---/ECRYPTFS_FNEK_ENCRYPTED.FYaYzpV4BZNwE-Qh48zmJMclYKU5FCiPjGrmS3RWzEDzFaf5QQQCBcFq8QigXiN.bw05hgK1C5JmGZrChgJVSOOVIACsXA9j5cx7
..
zip error: Out of memory (local_to_display_string)


Can someone tell me what I am doing wrong? Why can't I seem to create a zip file that excludes all files/directories from external drives including /media/*? If I read correctly, isn't the following the correct zip command syntax? If so, why does my output indicate directories from the excluded path being added (/media/My Book/.Trash-1000/*)?
zip -r FILENAME DIRECTORY_TO_ZIP -x PATH_TO_EXLUDE\*
For reference sake, here is what's in my root directory:

$ ls /
bin dev initrd.img lost+found opt sbin sys var
boot etc initrd.img.old media proc selinux tmp vmlinuz
cdrom home lib mnt root srv usr vmlinuz.old


Btw, I'm a newbie to Linux, so if this is basic, please excuse me.
 
Old 07-22-2010, 11:50 AM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 248Reputation: 248Reputation: 248
As far as I can see, -x works on files not directories.
I would have thought it would be easier to have multiple zip commands that each add a required directory to a single zip file.

Also, instead of quoting part of a path, quote the whole path.

cd /media/"My Book"/"Linux Backups"

Code:
 cd "/media/My Book/Linux Backups"
Also, please use code tags when pasting output or code.

Last edited by smoker; 07-22-2010 at 11:51 AM.
 
  


Reply

Tags
cli, exclude, zip


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CVS Exclude : Exclude sub directories from check out On Linux from command line shajay12 Linux - Newbie 1 08-03-2009 12:36 AM
How to exclude directories in tar? depam Linux - General 3 05-07-2007 08:23 PM
exclude directories from find noir911 Linux - General 3 11-22-2006 06:39 AM
KDAR Q-how to exclude directories... cbjhawks Suse/Novell 1 10-02-2006 04:05 PM
Tar won't exclude directories. yougene Slackware 9 12-01-2005 09:32 AM


All times are GMT -5. The time now is 02:01 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration