Skip to content

Instantly share code, notes, and snippets.

@Hemant-Mann
Last active October 1, 2015 13:35
Show Gist options
  • Save Hemant-Mann/2d35e4b6fb280b8910cd to your computer and use it in GitHub Desktop.
Save Hemant-Mann/2d35e4b6fb280b8910cd to your computer and use it in GitHub Desktop.
Bitbucket Backup
1. Login in to the server
----- Performed only once --------
2. Ensure SSH is installed
$ ssh -v
3. Setup default identity
a) $ ssh-keygen
(Choose the default location i.e. ~/ssh/id_rsa)
(Dont enter any passphrase)
b) Check the contents and you will find key files
$ ls -a ~/.ssh
----- Routine Steps (Only for Linux and MAC OS X < 10.6.8) -----
4. Start ssh-agent load the keys
a) Check if ssh-agent is running
$ ps -e | grep [s]sh-agent
Should see a ssh-agent process with an id
b) if not running then enter
$ ssh-agent /bin/bash
c) When ssh-agent is running load the default identity into memory
$ ssh-add ~/.ssh/id_rsa
d) List the keys the agent is managing
$ ssh-add -l
----------- Only Once ----------------
5. Install public key on Your/Team's Bitbucket Account
a) Find the public key
$ cat ~/.ssh/id_rsa.pub (In Linux) { Dumps key on stdout }
$ pbcopy < ~/.ssh/id_rsa.pub (OS X) { Copies directly to clipboard }
b) In Your account settings under ssh keys add a SSH Key and paste the public key copied from the above command
-------- Steps to be Repeated for every new repository --------
6. Make a private repository on bitbucket
7. Then 'cd' go to the website you want to backup
a) $ git init (Initialize empty repository)
b) $ git remote add origin [email protected]:<accountname>/<reponame>.git
c) $ git status (Check to see the uncommitted files which should be all the files)
c) $ git add --all
d) $ git commit -m "First Backup"
e) $ git push -u origin master (Whole website has been backed up to bitbucket)
------- For old Repositories --------
6. Load the ssh-keys in the ssh-agent. Then 'cd' to the repository
7. Check if it has valid origin for 'push' and 'pull'
a) $ git status
b) Commit any changes: $ git commit -m "{backup_no} Backup"
c) $ git push -u origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment