-
Notifications
You must be signed in to change notification settings - Fork 0
/
rsync-copy.bash
38 lines (33 loc) · 970 Bytes
/
rsync-copy.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# This code takes Date as input in YYYYMMDD Format.
# Copies the Files / FOlders to Destination if Source contains the files.
# It uses rsync command to copy files.
StartDate=`date +"%Y%m%d" -d $1` #"20160601"`
EndDate=`date +"%Y%m%d" -d $2` #"20160605"`
src=/home/yogesh/
dest=/home/cstechera/
if [ $# -ne 2 ]
then
echo "Usage:`basename $0` Start_Date End_Date"
echo "bash `basename $0` 20160601 20160605"
exit $E_BADARGS
fi
if [[ ! -d $src || ! -d $dest ]]
then
echo "Given Source or Destination Path does not Exists. Please check the Path."
exit $E_NOFILE
fi
echo "StartDate: "$StartDate
echo "EndDate: "$EndDate
echo "Source Path: "$src
echo "Destination Path: "$dest
while [ "$StartDate" -le "$EndDate" ] ;
do
if [ -d $src$StartDate ]
echo $src$StartDate
rsync $src$StartDate/*.* $dest$StartDate/
fi
# Increment Date by one day
StartDate=`date +"%Y%m%d" -d "$StartDate + 1 day"`;
done
echo "All Done"