-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths3fulltest.sh
executable file
·60 lines (44 loc) · 1.43 KB
/
s3fulltest.sh
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
S3_NAME=git-hub-192.168.0.1
BACKUP_DIR=/home/manojc/test-github/s3backup
password=March181987
account=manojchandrabss
repository=test-github
date=`date '+%Y%m%d%H%M%S'`
mkdir -p $BACKUP_DIR
for repository in test-github test-gits3test
do
echo "============Backing up $repository=============="
git clone --mirror https://github.com/$account/$repository.git $BACKUP_DIR/$repository.$date.git
if [ $? -ne 0 ]; then
echo "==========Error cloning $repository==========="
exit 1
else
echo "===========clone is successfull=========="
fi
tar cpzf $BACKUP_DIR/$repository.$date.git.tar.gz $BACKUP_DIR/$repository.$date.git
if [ $? -ne 0 ]; then
echo "=========Error compressing $repository==========="
exit 1
else
echo "===========compress is successfull========="
fi
echo "========moving Repository to S3-Bucket========="
if [ -f $BACKUP_DIR/$repository.$date.git.tar.gz ]; then
s3cmd put $BACKUP_DIR/$repository.$date.git.tar.gz s3://$S3_NAME/git.$repository.$date.git.tar.gz
fi
if [ $? -ne 0 ]; then
echo "Error uploading $repository to S3"
exit 1
else
echo "===========uploading successfully completed=========="
fi
#delete tar file and checked out folder
# /bin/rm $BACKUP_DIR/$repository.$date.git.tar.gz
# /bin/rm -rf $BACKUP_DIR/$repository.$date.git
# if [ $? -ne 0 ]; then
# echo "Error removing $repository"
# exit 1
# fi
done
echo "=========Succesfully backed up $repository==========="