Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alekcz/magma
A Clojure library to back up your Firestore to Google Storage
https://github.com/alekcz/magma
backup firebase firestore
Last synced: 1 day ago
JSON representation
A Clojure library to back up your Firestore to Google Storage
- Host: GitHub
- URL: https://github.com/alekcz/magma
- Owner: alekcz
- License: epl-2.0
- Created: 2020-01-29T17:49:07.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-28T12:31:59.000Z (over 4 years ago)
- Last Synced: 2024-05-28T12:39:27.853Z (6 months ago)
- Topics: backup, firebase, firestore
- Language: Clojure
- Homepage:
- Size: 30.3 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# magma
A Clojure library to back up your Firestore to Google Storage
![Clojure CI](https://github.com/alekcz/magma/workflows/Clojure%20CI/badge.svg) [![codecov](https://codecov.io/gh/alekcz/magma/branch/master/graph/badge.svg)](https://codecov.io/gh/alekcz/magma)
[![Clojars Project](https://img.shields.io/clojars/v/alekcz/magma.svg)](https://clojars.org/alekcz/magma)
## Usage
Environment variables:
1. GOOGLE_CLOUD_PROJECT contains the name of the project containing both firestore and the cloud storage
2. GOOGLE_APPLICATION_CREDENTIALS contains the `.json` credential for the service account being used.`magma` uses [alekcz/google-credentials](https://github.com/alekcz/google-credentials) to load Google Credentials from the `GOOGLE_APPLICATION_CREDENTIALS`
```clojure
[alekcz/magma "1.0.0"]
(require '[magma.core :as magma])
(magma/create-backup-bucket)
;by default the root is called magma-.
;The bucket is called named after the root(magma/list-firestore-backups)
(magma/last-firestore-backup)
(magma/backup-firestore)
(magma/backup-firestore "gs://bucket-name")(magma/restore-firestore "gs://bucket-name/yyyy-MM-ddTHH:mm:ss.SSS")
(magma/roll-back-firestore) ;for your safety magma waits 60 seconds before starting the roll back
(magma/deleting-your-backups-is-a-really-bad-idea "yyyy-MM-ddTHH:mm:ss_SSS")
;Renaming the root
(magma/rename-root "namespace")
; The root is now magma-namespace-
; This function primarily exists to enable testing
```I'm currently using `magma` to backup my DB just before I deploy a change to my production API.
## License
Copyright © 2020 Alexander Oloo
This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the Eclipse
Public License, v. 2.0 are satisfied: GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or (at your
option) any later version, with the GNU Classpath Exception which is available
at https://www.gnu.org/software/classpath/license.html.