As a DBA, I have a lot of scripts lying on my disk and have to copy it here and there which is very inconvenient and it’s hard to keep them synced to the latest version, if there was a change.
Now, I’ve turn to GIT which is a very popular tool at the moment. Below is how to build a public repository and add your scripts. Note, if you don’t want to share them (make them public), you have to pay for the service. But I really don’t think it’s necessary to make those management scripts “private”.
- Register a new user at Github: https://github.com/
- Download and install GIT on your client machine.If you’re using Linux, that’s pretty simple and straighforward, just use the preferred package manager of your Linux distribution. For CentOS, RHEL, Oracle Linux, make sure you have a YUM repository configured, and run “yum install git”. for other Linux, refer to http://git-scm.com/download/linux
- Setup GIT, create a repository, clone a repository to client machine and perform normal tasks against the repository. Details provided below.
- Note: To be able to login using https you should set your username to the git remote, then you will be asked for your password when tries to git pushgit remote set-url origin https://yourusername@github.com/user/repo.git
Example:
#Setup git - only do it once git config --global user.name "jasmine" git config --global user.email "jasmine@example.com" mkdir ~/scripts/oracle cd ~/scripts/oracle git init touch README git add README git commit -m 'first commit' git remote add origin https://jasmine@github.com/jasmine/repo.git git push origin master #Go to the Git local repository directory first: cd ~/scripts/oracle #clone git repository to other servers and make changes locally, then upload changed files to remote repository git clone https://github.com/jasmine/oracle.git ##make change on local repository git add . git commit -m "put some comments" git push #sync changs files from repository git pull #check status git status