A tool for backing up ATProto related data to S3

update the env variables to be clearer and update the readme

Signed-off-by: Will Andrews <did:plc:dadhhalkfcq3gucaq25hjqon>

Changed files
+29 -9
+4 -4
.env.example
···
-
ENDPOINT="S3-endpoint"
-
ACCESS_ID="S3-ID"
-
SECRET_ACCESS_KEY="S3-secret"
-
BUCKET_NAME="my-super-duper-bucket"
+
S3_ENDPOINT="S3-endpoint"
+
S3_ACCESS_ID="S3-ID"
+
S3_SECRET_ACCESS_KEY="S3-secret"
+
S3_BUCKET_NAME="my-super-duper-bucket"
DID="the-did-to-backup"
PDS_HOST="https://your-pds.com"
TANGLED_KNOT_DATABASE_DIRECTORY="/path/to/database/directory"
+4 -4
main.go
···
return
}
-
bucketName := os.Getenv("BUCKET_NAME")
+
bucketName := os.Getenv("S3_BUCKET_NAME")
err = minioClient.MakeBucket(ctx, bucketName, minio.MakeBucketOptions{})
if err != nil {
···
}
func createMinioClient() (*minio.Client, error) {
-
endpoint := os.Getenv("ENDPOINT")
-
accessKeyID := os.Getenv("ACCESS_ID")
-
secretAccessKey := os.Getenv("SECRET_ACCESS_KEY")
+
endpoint := os.Getenv("S3_ENDPOINT")
+
accessKeyID := os.Getenv("S3_ACCESS_ID")
+
secretAccessKey := os.Getenv("S3_SECRET_ACCESS_KEY")
useSSL := true
return minio.New(endpoint, &minio.Options{
+21 -1
readme.md
···
This is a tool I'm activly developing to back up my ATProtocol type things to S3 storage.
-
At the moment it's a one shot style script that backs up the PDS repo and then the blobs but in the future I plan on being able to backup other things (next is my Tangled Knot data).
+
Currently there are 2 things that can be backed up:
+
+
1: PDS data - A users repo and their blobs
+
2: Tangled Knot data - The repositories directory that contains all of the repo data and the directory that contains the SQLite database
The PDS repo data is pulled straight from the xrpc endpoint at sent straight to S3. The blob data however is streamed into a zip file and sent to S3 so that not all the data is held in memory while the backup takes place (the minio library will still keep some in memory as a multipart request).
It's very hacky right now and needs polishing to use with caution. Although let's face it, the worst it can do at the moment it backup some bad data which is better than no data 🤪
+
+
+
### How to use
+
+
Clone the repo and copy the `.env.example` file to be `.env`. Fill in the `.env` file with you S3 variables.
+
+
For PDS data backup you need to ensure that `DID` and `PDS_HOST` are populated.
+
+
For Knot data backup you need to ensure that `TANGLED_KNOT_DATABASE_DIRECTORY` and `TANGLED_KNOT_REPOSITORY_DIRECTORY` are populated.
+
+
Run `go run .`
+
+
### Todo
+
+
- [ ] - Turn this into a long running app using a cron library perhaps
+
- [ ] - User query params properly when creating the URLs to fetch repo and blobs
+
- [ ] - Allow configuring the backup of knot repo data per users DID maybe?