Created
November 17, 2015 12:50
-
-
Save merajsiddiqui/51f32b205549b4810260 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#for Help use this link https://gist.github.com/Hemant-Mann/2d35e4b6fb280b8910cd | |
#! /bin/bash | |
#This is the Program to backup your server code by ssh method to bitbucket | |
#All you need to do is go to bitbucket account create a repository and copy the pucblic ssh key to the repository access | |
#Copy the repositry name here we will create a backup automatically | |
mysql -u root -pabcroot -e "SELECT * FROM admin_test.Backup">backup.csv | |
cat backup.csv | while read id user repository | |
do | |
if [ "$id" != "id" ]; | |
then | |
cd /var/www/html/TestShell/"$user"/"$repository"/ | |
#check if a file is allready a git repo | |
if [ ! -d ".git" ] | |
then | |
#If not then make it a git repo | |
git init | |
git remote add origin [email protected]:cloudstuff/"$repository".git | |
ssh-agent /bin/bash | |
ssh-add ~/.ssh/id_rsa | |
ssh-add -l | |
fi | |
git add --all | |
git commit -m "WeekLy Backup" | |
git push -u origin master | |
cd ~ | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modify the path to cd it may vary like
/home/meraj/web/codecite.com/public_html/
username - meraj
repository name - codecite.com
As you add a domain don't forget to add bitbucet repository name as domain name
So you can have a seprate backup for each domains code
Here we use a database so a non tech team member can just put the details here so it will auto backup