GitHub With Wasabi
    • 19 Jun 2024
    • 1 Minute to read
    • PDF

    GitHub With Wasabi

    • PDF

    Article summary

    How do I use GitHub with Wasabi?

    Backing up GitHub (Git) repository becomes essential when you want to save your repo from accidental deletion of files. Below is a script which allows you to backup a Git repo to a Wasabi bucket.

    Note: Please be sure to save the Wasabi access keys in the "~/.aws/credentials" file with profile name "wasabi"

    #!/bin/bash
    
    #parameters to perform backup. These parameters can also be passed as environmental variables
    bucket=""
    dir=""
    password=""
    account=""
    repository=""
    date=`date '+%Y%m%d%H%M%S'`
    
    #Clone the repository to a local directory
    mkdir -p $dir
    git clone --mirror git@github.com:$account/$repository.git $dir/$repository.$date.git
    
    #Compress the cloned repository
    tar cpzf $dir/$repository.$date.git.tar.gz $dir/$repository.$date.git
    
    #Transfer compressed repository to Wasabi
    if [ -f $dir/$repository.$date.git.tar.gz ]; then
     aws s3 cp $dir/$repository.$date.git.tar.gz s3://$bucket/git.$repository.$date.git.tar.gz --profile wasabi --endpoint-url=https://s3.wasabisys.com
    fi
    
    #delete tar file and checked out folder
    /bin/rm $dir/$repository.$date.git.tar.gz
    /bin/rm -rf $dir/$repository.$date.git
    

    Note that this example discusses the use of Wasabi's us-east-1 storage region. To use other Wasabi storage regions, please use the appropriate Wasabi service URL as described in this article