Giter VIP home page Giter VIP logo

gitlab-backup-uploader's Introduction

Gitlab Backup Uploader

Script to upload Gitlab backups to Google Drive for Linux systems


Install:

Make a repository copy to the GitLab home directory.

cd /home/git
git clone https://github.com/pquerner/gitlab-backup-uploader.git

I recommend using this uploader via git clone instead of downloading, so you can benefit from automatic update scripts.

Download and install the Google Drive CLI for your system. This has been tested with version 2.1.0 Linux x64 (Ubuntu).

wget https://docs.google.com/uc?id=0B3X9GlR6EmbnQ0FtZmJJUXEyRTA -O drive
chmod a+x drive
sudo mv /home/git/drive /usr/bin/

Run Google Drive CLI and configure it with your Google Account Drive that will receive the files. When running, follow the instructions that appear on the terminal.

drive

After configuring the Google Drive CLI, create a directory in Google Drive, and get his ID. Example: if the URL of the directory on Google Drive is this:

https://drive.google.com/drive/u/0/#folders/0B43Qn3ksX-mMRzl1S05mbDNIdGc

the directory ID is the part that is left after /#folders/. In other words:

0B43Qn3ksX-mMRzl1S05mbDNIdGc

With ID in hand, register it in the configuration file. How to do that?

Make a copy of the example configuration file:

cd /home/git/gitlab-backup-uploader/conf
cp upload.cfg.example upload.cfg

Edit upload.cfg, and change the following items:

  • The parameter GITLAB_BACKUPS with the full path of the GitLab backup directory.
  • The parameter GDRIVE_DIRECTORY_ID with the Google Drive directory ID that will receive the backup files.
  • The parameter UPLOAD_COMPRESS_FILE to decide whether the backup will be compressed prior to upload.
  • The parameter ENCRYPT_FILE to decide whether the backup will be encrypted prior to upload.
  • The parameter ENCRYPT_PASSWORD_FILE to the file which holds the private password for GPG to use (plaintext). Keep this file safe!

Then just put the upload script in crontab (com crontab -e):

# Upload the latest GitLab backup to Google Drive at 10pm.
0 22 * * * /home/git/gitlab-backup-uploader/gitlab-backup-upload.sh 1> /home/git/gitlab-backup-uploader/log/cron.log 2>&1

Parameters

The shell script "gitlab-backup-upload" accepts the following optional parameters:

-c = Configuration file to use. Defaults to /conf/upload.cfg
Reason:
    If you save your /etc/gitlab directory from a cronjob for instance, you can save it with this script also.
    (Example cronjob : tar cfz /var/opt/gitlab/backups/opt/$(date "+opt-gitlab-%s.tgz") -C / opt/gitlab)
-d = Dry-run mode. Does not actually do anything but shows what would be done. Good for testing.
-k = Keep old uploaded file. Normally this script deletes the last uploaded file uploaded to your GDrive account. This parameters prevents that action.

Update

Check if any new configuration variables exists in conf/upload.cfg.exmaple and if there is, add them to your existing configuration file.

Changelog

#####initial to "v0.1.12" refer to git log

#####"v0.1.12" to "v0.1.13" Added GPG encryption of backup file.
This version added a new configuration variable to the configuration file


License

Copyright 2014 Syonet CRM

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

gitlab-backup-uploader's People

Stargazers

 avatar

Watchers

 avatar  avatar

gitlab-backup-uploader's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.