Skip to content

Commit

Permalink
Merge pull request #24 from theanupambista/main
Browse files Browse the repository at this point in the history
Refactor: Cli configured according to yaml and used vitepress for documentation of each command
  • Loading branch information
isarojdahal authored Oct 5, 2024
2 parents a4b8860 + b110ef3 commit 199186e
Show file tree
Hide file tree
Showing 39 changed files with 5,359 additions and 521 deletions.
26 changes: 0 additions & 26 deletions .env.sample

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Deploy VitePress site to Pages

on:
push:
branches: [main]
paths:
- "docs/**" # Only trigger when files in the docs/ directory change

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Not needed if lastUpdated is not enabled
- uses: pnpm/action-setup@v3 # Uncomment this if you're using pnpm
# - uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm # or pnpm / yarn
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Install dependencies
run: pnpm install # or pnpm install / yarn install / bun install
- name: Build with VitePress
run: pnpm docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
node_modules
log
.sql
pnpm-lock.yaml
yarn.lock
package-lock.json
.env
Expand All @@ -14,4 +13,6 @@ limited_dump.sql
tmp/
config.ts
backupdbee.yaml
backupdbee.yml
backupdbee.yml
docs/.vitepress/dist
docs/.vitepress/cache
33 changes: 2 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,9 @@ Effortlessly manage your database backups at one go. This easy-to-use tool suppo

✅ Automated Backups: Schedule and automate backups (using crons or pm2) to ensure your data is always protected without manual intervention.

## Clone the project 📦
## Documentation

```
git clone https://github.com/28softwares/backupdbee.git
cd backupdbee
```

### Initial Setup

Make sure to install nodejs and zip in the linux server.

```bash
node index.mjs install #this creates .env file
```

### Configurations ⚒️

For GMAIL, you need to enable less secure apps in your gmail account. [Click here to enable less secure apps](https://myaccount.google.com/lesssecureapps)

```bash
crontab -e

#at the crontab file, add the following script.
#minute hour dayOfMonth month dayOfWeek commandToRun
* * * * * commandToRun {_ can be any value}~~
```

_OR, you can use process managers as_

```
pm2 start src/index.mjs --name dbbackup --cron "* * * * *"
```
Check out the documentation at: [https://28softwares.github.com/BackupDBee](https://28softwares.github.com/BackupDBee)

## Feel Free To Contribute 👌

Expand Down
5 changes: 1 addition & 4 deletions backupdbee.yaml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ destinations:
smtp_port: 587
smtp_username:
smtp_password:

notifications:
email:
enabled: false
from: [email protected]
to:
- [email protected]

notifications:
slack:
enabled: true
webhook_url: https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXXXXX
Expand Down
54 changes: 54 additions & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { defineConfig, type DefaultTheme } from "vitepress";

// https://vitepress.dev/reference/site-config
export default defineConfig({
base: "/BackupDBee/",
title: "BackupDBee 🐝",
description: "Automatic CLI Based Advance DB Backup System",
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: "Home", link: "/" },
{
text: "Guide",
link: "/guide/what-is-backupdbee",
activeMatch: "/guide/",
},
],

sidebar: {
"/guide/": { base: "/guide/", items: sidebarGuide() },
},

socialLinks: [
{ icon: "github", link: "https://github.com/28softwares/BackupDBee" },
],
},
});

function sidebarGuide(): DefaultTheme.SidebarItem[] {
return [
{
text: "Introduction",
collapsed: false,
items: [
{ text: "What is backupdbee?", link: "what-is-backupdbee" },
{ text: "Getting Started", link: "getting-started" },
{ text: "Configuration", link: "configuration" },
],
},
{
text: "Cli Commands",
collapsed: false,
items: [
{ text: "general", link: "cli/general" },
{ text: "db:list", link: "cli/db-list" },
{ text: "db:backup", link: "cli/db-backup" },
],
},
{
text: "Automation",
link: "automate-backup",
},
];
}
49 changes: 49 additions & 0 deletions docs/api-examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
outline: deep
---

# Runtime API Examples

This page demonstrates usage of some of the runtime APIs provided by VitePress.

The main `useData()` API can be used to access site, theme, and page data for the current page. It works in both `.md` and `.vue` files:

```md
<script setup>
import { useData } from 'vitepress'

const { theme, page, frontmatter } = useData()
</script>

## Results

### Theme Data
<pre>{{ theme }}</pre>

### Page Data
<pre>{{ page }}</pre>

### Page Frontmatter
<pre>{{ frontmatter }}</pre>
```

<script setup>
import { useData } from 'vitepress'

const { site, theme, page, frontmatter } = useData()
</script>

## Results

### Theme Data
<pre>{{ theme }}</pre>

### Page Data
<pre>{{ page }}</pre>

### Page Frontmatter
<pre>{{ frontmatter }}</pre>

## More

Check out the documentation for the [full list of runtime APIs](https://vitepress.dev/reference/runtime-api#usedata).
7 changes: 7 additions & 0 deletions docs/guide/automate-backup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Automate Backup

You can use process managers to automate your backup

```bash
pm2 start ts-node index.ts db:backup --name dbbackup --cron "* * * * *"
```
29 changes: 29 additions & 0 deletions docs/guide/cli/db-backup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# `db:backup` Command Documentation

The `db:backup` command is used to back up all databases defined in the YAML configuration or specific ones using the `--name` flag. You can pass multiple databases to `--name` flag by providing a comma-separated list of database names.

## Usage

### Backup All Databases

To back up all databases, simply run the following command:

```bash
ts-node index.ts db:backup
```

### Backup Specific Database(s)

To back up one or more specific databases, use the `--name` flag followed by the database name(s). You can provide a single database name or multiple names separated by commas.

#### Backup a Single Database:

```bash
ts-node index.ts db:backup --name <database_name>
```

#### Backup Multiple Databases:

```bash
ts-node index.ts db:backup --name <database_name_1>,<database_name_2>,<database_name_3>
```
11 changes: 11 additions & 0 deletions docs/guide/cli/db-list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `db:list` Command Documentation

The `db:list` command lists all the databases defined in the YAML configuration file and shows the total count of databases.

## Usage

Run the following command in your terminal:

```bash
ts-node index.ts db:list
```
41 changes: 41 additions & 0 deletions docs/guide/cli/general.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# `general` Command Documentation

The `general` command is used to configure the general settings of your `backupdbee.yaml` file. You can either use flags to update specific settings or use an interactive mode where you'll be prompted to provide input.

## Command: `general`

```bash
ts-node index.ts general [options]
```

### Description

The `general` command allows you to modify the following general settings in the `backupdbee.yaml` file:

- Backup location
- Log location
- Log level (INFO, DEBUG, ERROR)
- Retention policy (number of days)
- Backup schedule (in cron format)

You can configure each setting individually using the provided flags or choose to use the interactive mode (i.e., no flags) to update settings step-by-step.

---

## Flags

Below is a table describing each flag you can use with the `general` command.

| Flag | Description | Example Command |
| -------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------- |
| `--backup-location` | Specify the directory where backups will be stored. | `ts-node index.ts general --backup-location "/path/to/backups"` |
| `--log-location` | Set the directory where logs will be stored. | `ts-node index.ts general --log-location "/path/to/logs"` |
| `--log-level` | Set the log verbosity level. Accepts values: `INFO`, `DEBUG`, `ERROR`. | `ts-node index.ts general --log-level DEBUG` |
| `--retention-policy` | Specify how many days backups will be retained. Takes a number as an input. | `ts-node index.ts general --retention-policy 10` |
| `--backup-schedule` | Set the cron schedule for automatic backups. | `ts-node index.ts general --backup-schedule "0 3 * * *"` |

---

## Interactive Mode

If no flags are provided, the `general` command will enter an interactive mode, where you will be prompted to input values for each setting.
Loading

0 comments on commit 199186e

Please sign in to comment.