Copy of directory, partially

Is there a simple shell command/script that
supports excluding certain files/folders from being copied?
There is

cp  -R /opt/lampp/htdocs/ockham/   /home/vlm/BACKUP/OCKHAM/ockham_$(date "+%m_%d_%y_%H-%M")
if [ $? == 0 ]; then echo 'Copy PC- OK !!!';
else 
echo 'No, Error.';
fi

There exists /ockham/picture with jpg-files.
They, katalog picture must not been copied.
How can I do it?
Thank you.

1 Like

It is really easy with rsync.

rsync --exclude='something-to-exclude' /path/to/source /path/to/destination
4 Likes

Thanks, I will try.

1 Like

rsync = the one indeed…

1 Like

Thank you,
this works !

Screenshot from 2022-10-26 13-01-17

Was it this command, the solution ? :wink: :innocent:

2 Likes

i correct this… and not a command only my comment :blush:

2 Likes

Text below :

rsync -ar --exclude 'assets/pictures/' /opt/lampp/htdocs/ockham/ /home/vlm/BACKUP/OCKHAM/ockham_$(date "+%m_%d_%y_%H-%M")
if [ $? == 0 ]; then echo 'Copy PC- OK !!!';
else 
echo 'No, Error.';
fi
rsync -ar --exclude 'assets/pictures/' /opt/lampp/htdocs/ockham/ /run/media/vlm/INTENSO/OCKHAM/ockham_$(date "+%m_%d_%y_%H-%M")
if [ $? == 0 ]; then echo 'Copy Stick- OK !!!';
else 
echo 'No, Error.';
fi

And once again - THANKS !!!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.