Wertik JS allows adding support for third party Storage services to your app. As of today 28 November 2021, Wertik JS supports digitalocean
and dropbox
. To use storage services you need to use useStorage
function from wertik-js.
import wertik, { useStorage } from "wertik-js/lib/";
wertik({
port: 1200,
storage: {
digitalocean: useStorage({
for: "digitalocean",
name: "digitalocean",
digitalOceanOptions: {
accessKeyId: "",
secretAccessKey: "",
spacesEndpoint: "",
},
}),
dropbox: useStorage({
for: "dropbox",
name: "dropbox",
dropboxOptions: {
accessToken: "",
},
}),
},
});
This will print in console:
[Storage] Initialized Digital Ocean instance digitalocean
[Storage] Initialized Dropbox instance dropbox
aws-sdk
package for uploading files.dropbox
package for uploading files.Wertik JS provides a builtin module to take backups of your database called Backup. To use it, it requires a table called Backup
with following fields:
To use it You can import it from Wertik JS:
import wertik, { WertikBackupModule } from "wertik-js/lib/";
wertik({
port: 1200,
modules: {
// Database name and table to insert backup information. Make sure you have a database connection.
backup: WertikBackupModule("databasename", "tablename"),
},
});
Accroding to upload status Wertik JS will fill up the table. To backup you need to use GraphQL mutations that are built already:
mutation {
backupLocal(database: ["jscontainer"]) {
message
filename
backup {
id
uploaded_to
uploaded_filename
}
}
}
Response:
{
"data": {
"backupLocal": [
{
"message": "Backup was successfull",
"filename": "backups/november-29-2021-4-46-42-am-database-jscontainer.sql",
"backup": {
"id": 35,
"uploaded_to": "local",
"uploaded_filename": "backups/november-29-2021-4-46-42-am-database-jscontainer.sql"
}
}
]
}
}
mutation {
backupDigitalOceanSpaces(
ACL: "private"
Bucket: "your-bucket-name"
storage: "digitalocean"
database: ["jscontainer"]
) {
message
filename
backup {
uploaded_to
uploaded_filename
}
}
}
{
"data": {
"backupDigitalOceanSpaces": [
{
"message": "Backup was successfull",
"filename": "backups/november-29-2021-5-29-57-am-database-jscontainer.sql",
"backup": {
"uploaded_to": "digitalocean",
"uploaded_filename": "backups/november-29-2021-5-29-57-am-database-jscontainer.sql"
}
}
]
}
}
Note: Make sure your dropbox app has right permissions to write files to your dropbox.
mutation {
backupDropbox(storage: "dropbox", database: ["jscontainer"]) {
message
filename
backup {
uploaded_to
uploaded_filename
}
}
}
{
"data": {
"backupDropbox": [
{
"message": "Backup was successfull",
"filename": "backups/november-29-2021-5-14-02-am-database-jscontainer.sql",
"backup": {
"uploaded_to": "dropbox",
"uploaded_filename": "/backups/november-29-2021-5-14-02-am-database-jscontainer.sql"
}
}
]
}
}