# Backup your space to Github

**URL:** https://community.silverbullet.md/t/backup-your-space-to-github/798
**Category:** Guides
**Created:** [August 4, 2024, 7:26pm UTC](https://community.silverbullet.md/t/backup-your-space-to-github/798 "2024-08-04T19:26:32Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)
#### Post date: [August 4, 2024, 7:26pm UTC](https://community.silverbullet.md/t/backup-your-space-to-github/798/1 "2024-08-04T19:26:32Z")

</div>

Personally I use a private Github repository for backing up my space. This is how I set this up.

## Requirements

- A (free) Github account
- A private Github repository to keep your space files

## Create a token

We will authenticate with Github via HTTPS and a _personal access token_. This is relatively safe and simple to setup.

Go to your [Personal Access Tokens](https://github.com/settings/tokens) page, and Generate a new token (beta) scoped to your repository.

- Select a expiry date far in the future
- Select: “Only selected repositories” and select your private space repostiory.
- For permissions choose:
  - Contents: Read & Write

Then generate the token. Save the token some place safe, you will need it later in a bit.

## Get a shell

If you’re running SilverBullet directly on your machine, you can just `cd` into your space folder and use `git` from there (if it is installed, if not, install git first).

If you’re running inside of a docker container you need to get a shell into your container.

Using docker you can do this with `docker exec`. For instance, if your container is named `silverbullet` you can run:

```shell
docker exec -it silverbullet /bin/bash

```

By default you will be `root`. It's important you perform the actions below as the same user as which silverbullet is running, to check which user this is, in the docker shell run:

```bash
ps aux

```

Look for a line that looks like this:

```auto
 14 silverbu 0:00 /silverbullet

```

This will either list a user (second column) named `silverbu` (don't mind that it's truncated) or `root`. If it's `silverbu`, `su` into this user before continuing:

```bash
su silverbullet

```

## Configure the git repository

In your shell:

```shell
# Change to the space folder, in docker this is always /space
cd /space
# Initialize it as a git repo
git init
# Configure your name and email
git config user.name "Your Name"
git config user.email "your@email.com"
# Set rebasing to false (or true if you prefer)
git config pull.rebase false
# Add the Github repository you created as a remote, replace GITHUBTOKEN with the token you received earlier
git remote add origin https://GITHUBTOKEN@github.com/username/repo.git

```

## Empty repository

If you created a fresh Github repository with no content yet, you can do the following:

```shell
# Set the branch to main
git branch -m main
# Configure the default upstream
git branch --set-upstream-to=origin/main main
# Add all existing files
git add *.md
# Commit the first version
git commit -m "Initial commit"
# Push the first version
git push origin main

```

## Existing content

If your repository already has content, first clean out the auto generated files ([index.md](http://index.md) and [CONFIG.md](http://CONFIG.md)), then checkout the remote branch:

```shell
# Fetch all branches from the remote repostiroy
git fetch
# Clean out the auto generated pages
rm index.md SETTINGS.md
# Checkout your main branch from the repository
git checkout main

```

## Installing the Git library

Open the SilverBullet Library Manager with the `Library: Manager` command, look for the "Git" library, and click "Install" to install it.

This will give you some useful `Git: *` commands. Click on the link for the Git library in the "Installed Libraries" section for more information on how to use the integration.

Enjoy!

---

<div class="post-metadata">

### Author: ![vuau](https://community.silverbullet.md/user_avatar/community.silverbullet.md/vuau/32/554_2.png) [@vuau](https://community.silverbullet.md/u/vuau)
#### Post date: [August 30, 2024, 3:39am UTC](https://community.silverbullet.md/t/backup-your-space-to-github/798/2 "2024-08-30T03:39:20Z")

</div>

I deployed SilverBullet to [fly.io](http://fly.io) then I used the git plug to backup my space to Github. The problem is that I can sync it manually but the autoSync and autoCommit feature seem not working. Is that a limitation of [fly.io](http://fly.io) or did I do something wrong?

---

<div class="post-metadata">

### Author: ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)
#### Post date: [August 30, 2024, 4:03am UTC](https://community.silverbullet.md/t/backup-your-space-to-github/798/3 "2024-08-30T04:03:41Z")

</div>

I think it works only if you keep your fly machine active. Fly stops machines after a few minutes of inactivity, and then the auto commit stuff also won’t run.

---

<div class="post-metadata">

### Author: ![vuau](https://community.silverbullet.md/user_avatar/community.silverbullet.md/vuau/32/554_2.png) [@vuau](https://community.silverbullet.md/u/vuau)
#### Post date: [August 30, 2024, 8:27am UTC](https://community.silverbullet.md/t/backup-your-space-to-github/798/4 "2024-08-30T08:27:26Z")

</div>

I worked around it by using space-script to call git.syncCommand whenever a page is saved

---

<div class="post-metadata">

### Author: ![Matt](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@Matt](https://community.silverbullet.md/u/Matt)
#### Post date: [September 25, 2024, 5:42pm UTC](https://community.silverbullet.md/t/backup-your-space-to-github/798/5 "2024-09-25T17:42:27Z")

</div>

I also assume it’s a good idea to include a .gitignore with the below contents. @zef, could you confirm this is correct and if any others are suggested?

```auto
.silverbullet.db*
_plug/
Library/

```

I noticed Library/Personal/\* is recommended for storing templates/library edits, so this should be included in git, correct?

---

<div class="post-metadata">

### Author: ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)
#### Post date: [September 25, 2024, 6:48pm UTC](https://community.silverbullet.md/t/backup-your-space-to-github/798/6 "2024-09-25T18:48:58Z")

</div>

Yes, this is roughly the .gitignore I use as well, except that I just commit the Library folder as well because… why not 🙂 Excluding .silverbullet.db\* and \_plug is indeed a good idea.

---

<div class="post-metadata">

### Author: ![bearded-papa](https://community.silverbullet.md/user_avatar/community.silverbullet.md/bearded-papa/32/715_2.png) [@bearded-papa](https://community.silverbullet.md/u/bearded-papa)
#### Post date: [November 4, 2024, 8:43pm UTC](https://community.silverbullet.md/t/backup-your-space-to-github/798/7 "2024-11-04T20:43:36Z")

</div>

I have tried to follow this to the letter but keep getting this everytime I try the first commit

```auto
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.

```

---

<div class="post-metadata">

### Author: ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)
#### Post date: [November 27, 2025, 8:24pm UTC](https://community.silverbullet.md/t/backup-your-space-to-github/798/8 "2025-11-27T20:24:04Z")

</div>

## Updates

(updated in original post)

- 2025-11-27: Updated to use the Git library instead of plug, added `su` instructions since docker images may switch user

---

<div class="post-metadata">

### Author: ![Sam](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/s/5f9b8f/32.png) [@Sam](https://community.silverbullet.md/u/Sam)
#### Post date: [May 18, 2026, 10:29pm UTC](https://community.silverbullet.md/t/backup-your-space-to-github/798/9 "2026-05-18T22:29:15Z")

</div>

I just wanted to mention, that your Git lib also works fine with Forgejo, where i created a personal access token and used that one for auth. In other words: a Github repository is not a strong requirement here.

---

<div class="post-metadata">

### Author: ![patxque](https://community.silverbullet.md/user_avatar/community.silverbullet.md/patxque/32/3551_2.png) [@patxque](https://community.silverbullet.md/u/patxque)
#### Post date: [May 22, 2026, 11:38pm UTC](https://community.silverbullet.md/t/backup-your-space-to-github/798/10 "2026-05-22T23:38:23Z")

</div>

As someone who does not use Git often I will add that GitHub desktop works just fine as well.
