How do I restore a repository from S3 backups?
All business-level accounts in Beanstalk support optional backups to Amazon S3. You can use instructions from this article to restore your Git or Subversion repository from your S3 bucket if you had backups enabled in your account.
Locate your S3 bucket
In order to restore your repositories you need to obtain the same AWS Access and Secret keys that you specified in Beanstalk when you first enabled the backups. You also need to find out what bucket Beanstalk is using for backups. You can see the bucket name on Account → Backups page inside your Beanstalk account. Please note that only the account owner has access to that page.
Once you have all the necessary information (access key, secret key and bucket name) you can use one of the many AWS S3 clients to connect to your bucket. My personal favorite is Transmit for Mac.
Use the client to connect to your bucket. After connecting you will see a directory named "accXX" where XX would be your account ID. Inside that directory you will find a list of directories where each directory would represent a repository from your Beanstalk account. You can either download all of these directories to your computer (if you want to restore all repositories) or pick the one you want to restore and download it separately. Wait until file transfer is complete before proceeding to the next step.
Restoring a Git repository
In order to push a Git repository that you downloaded from S3 back to Beanstalk or a different provider, follow the steps:
- Make sure you have Git installed on your computer and you have command line access.
- In command line
cd
into repository directory that you downloaded from S3. - Run the clone command if you do not already have a Git repo initialized in the desired directory.
- Use
git remote add
command to add a new remote to which you would like to push your repository. This can be either an empty Git repository in Beanstalk or some other provider. - Run
git push remotename --all
to push all branches from your local repository to the remote. Don't forget to specify the correct remote name that you added.
Restoring a Subversion repository
The best way to restore an SVN repository would be to create a Subversion dump out of the directory that you downloaded from S3 first. Follow the steps:
- Make sure you have command-line SVN installed on your computer.
- In command line
cd
into repository directory that you downloaded from S3. - Run
svnadmin dump . > ../repo.dump
command from inside the directory to create a dump. Wait until it's finished. - You can now use that dump file to import the repository back into Beanstalk or any other provider.