Git Product home page Git Product logo

gitlabbackuputil's Introduction

GitlabBackupUtil

A Small utility to backup all of your gitlab repositories to local filesystem. You never know when international laws change and you loose access to your repos.

It is painful for me to hear how trade restrictions have hurt people. We have gone to great lengths to do no more than what is required by the law, but of course people are still affected. GitHub is subject to US trade law, just like any company that does business in the US.

โ€” Nat Friedman (@natfriedman) July 28, 2019

How to Backup

Backup using http (default)

npm install -g gitlab-backup-util
gitlab-backup-util -t 'your-gl-token-here'

Backup using ssh

gitlab-backup-util -t 'your-gl-token-here' -m ssh

Future Scope

    • [โœ”] If the repository already exists, git pull instead of cloning
    • Gui for entering token

Thats It ๐Ÿš€, Now go backup

gitlabbackuputil's People

Contributors

4security avatar amir-ameri avatar anton-nikishkin avatar atounde avatar dependabot[bot] avatar itsteknas avatar proximab avatar pyropy avatar stephen-reaves avatar unfailing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gitlabbackuputil's Issues

Always ask for login

It's not work for me, a few messages to insert login and after a password, and it goes for a loop, round and round, again =(

ERROR

`sudo gitlab-backup-util -t 'sMxCeS1AjD8tEMGHJiTd' -m ssh

(node:21068) UnhandledPromiseRejectionWarning: StatusCodeError: 401 - {"message":"401 Unauthorized"}
at new StatusCodeError (/usr/local/lib/node_modules/gitlab-backup-util/node_modules/request-promise-core/lib/errors.js:32:15)
at Request.plumbing.callback (/usr/local/lib/node_modules/gitlab-backup-util/node_modules/request-promise-core/lib/plumbing.js:104:33)
at Request.RP$callback [as _callback] (/usr/local/lib/node_modules/gitlab-backup-util/node_modules/request-promise-core/lib/plumbing.js:46:31)
at Request.self.callback (/usr/local/lib/node_modules/gitlab-backup-util/node_modules/request/request.js:185:22)
at Request.emit (events.js:198:13)
at Request. (/usr/local/lib/node_modules/gitlab-backup-util/node_modules/request/request.js:1154:10)
at Request.emit (events.js:198:13)
at IncomingMessage. (/usr/local/lib/node_modules/gitlab-backup-util/node_modules/request/request.js:1076:12)
at Object.onceWrapper (events.js:286:20)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1129:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
(node:21068) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:21068) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
`

For whom wants to use this against a self-hosted gitlab instance, and self-signed or expired ssl

Please modify the index.js as following

diff --git a/index.js b/index.js
index b6bffca..5d178c8 100644
--- a/index.js
+++ b/index.js
@@ -10,11 +10,12 @@ const token = tokenJson.token;
 
 (async () => {
 
-  let groups = await rp.get('https://www.gitlab.com/api/v4/groups?per_page=999', {
+  let groups = await rp.get('https://example.com/api/v4/groups?per_page=999', {
     json: true,
     qs: {
       simple: true,
     },
+    rejectUnauthorized: false,
     headers: {
       'PRIVATE-TOKEN': token
     }
@@ -23,11 +24,12 @@ const token = tokenJson.token;
   let gids = _.map(groups, 'id')
   let pgits = []
   for (let gid of gids) {
-    let projects = await rp.get(`https://www.gitlab.com/api/v4/groups/${gid}/projects?per_page=999`, {
+    let projects = await rp.get(`https://example.com/api/v4/groups/${gid}/projects?per_page=999`, {
       json: true,
       qs: {
         simple: true,
       },
+      rejectUnauthorized: false,
       headers: {
         'PRIVATE-TOKEN': token
       }
@@ -45,6 +47,6 @@ const token = tokenJson.token;
   for (let git of pgits) {
     const repoName = git.substring(19, git.length - 4)
     console.log(`Cloning ${repoName}`)
-    const stdout = await cmdAsync(`git clone ${git} backup/${repoName}`)
+    const stdout = await cmdAsync(`git -c http.sslVerify=false clone ${git} backup/${repoName}`)
   }
 })()

Fetches only 100 projects per project-group

If one gitlab project-group contains more than 100 projects, it fetches only 100 projects. Although on API call it was mentioned per_page=999 but I guess this doesn't work.

Cloning not being done using token

Running this tool:

gitlab-backup-util -t 'glpat-XXXXXXXXXXXXXXXXXXXx'

Results in it listing the projects ("Got Project xxxx").
After some time it however asks for the username and password. This is not needed if the PAT is being used to clone the repos, like so:

git clone https://:[email protected]/group/project.git

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.