I want to copy a folder to another location, while excluding some specific files
Here is my current script:
#!/bin/bash
if [ -n "$2" ]
then
source=$(readlink -f $1)
destination=$(readlink -f $2)
else
printf "\nProper syntax: my_copy source_folder destination_folder\n"
exit
fi
params=(
--exclude='.git'
--exclude='deploy'
--exclude='app/config/database.php'
--exclude='app/config/config.php'
)
cd $source
rsync " -a ${params[@]} $source/* $destination"
When I run my script, I get this error:
rsync: link_stat "-a --exclude=.git" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1070) [sender=3.0.9]
What am I doing wrong?
rsync -a "${params[@]}" $source/ $destination
if not work then tryecho rsync -a "${params[@]}" $source/ $destination| sh
– Rahul Patil Sep 10 '13 at 11:30