-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vishal Anarase <[email protected]>
- Loading branch information
Vishal Anarase
committed
Jan 31, 2024
1 parent
11ac765
commit 917217d
Showing
4 changed files
with
153 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
|
||
# Database Backup and Restore | ||
|
||
> This repository provides a solution for backing up and restoring databases. Whether you need scheduled backups for automated routine tasks or manual backups for specific events, this guide will walk you through the process. | ||
## Backup Types | ||
|
||
### Scheduled Backups | ||
|
||
Scheduled backups are automated processes that run at predefined intervals. They help ensure that your data is regularly backed up without manual intervention. | ||
|
||
To set up scheduled backups, follow the steps outlined in the Configuration section. | ||
|
||
* Support: PostgreSQL | ||
|
||
### Manual Backups | ||
|
||
Manual backups are initiated by a user on-demand. These are useful for creating backups before system updates, major changes, or any event that requires a snapshot of the database at a specific point in time. | ||
|
||
To manually create a backup, follow the steps outlined in the Usage section. | ||
|
||
* Support: PostgreSQL, MySQL | ||
|
||
### Restore Process | ||
|
||
The restore process allows you to recover your database from a previously created backup. | ||
|
||
* Support: PostgreSQL, MySQL | ||
|
||
# CLI Operations | ||
|
||
## Create MySQL and PostgreSQL database | ||
|
||
```bash | ||
❯ ./civo --config staging.civo.json database create postgres-demo --size g3.db.medium --software PostgreSQL --version 14 | ||
Database (postgres-demo) with ID 65dd8173-f754-4c6c-b50a-7ddb6d5446c5 has been created | ||
``` | ||
|
||
```bash | ||
❯ ./civo --config staging.civo.json database create mysql-demo --size g3.db.medium --software MySQL --version 8.0 | ||
Database (mysql-demo) with ID 0d328d59-98c3-4f68-8025-5b1633a1c287 has been created | ||
``` | ||
|
||
```bash | ||
❯ ./civo --config staging.civo.json database ls | ||
+--------+---------------+--------------+-------+------------+------------------+--------------+------+--------+ | ||
| ID | Name | Size | Nodes | Software | Software Version | Host | Port | Status | | ||
+--------+---------------+--------------+-------+------------+------------------+--------------+------+--------+ | ||
| 65dd81 | postgres-demo | g3.db.medium | 1 | PostgreSQL | 14 | 31.28.88.149 | 5432 | Ready | | ||
+--------+---------------+--------------+-------+------------+------------------+--------------+------+--------+ | ||
| 0d328d | mysql-demo | g3.db.medium | 1 | MySQL | 8.0 | 31.28.88.184 | 3306 | Ready | | ||
+--------+---------------+--------------+-------+------------+------------------+--------------+------+--------+ | ||
To get the credentials for a database, use `civo db credential <name/ID>` | ||
``` | ||
|
||
### List database backups | ||
|
||
```bash | ||
❯ ./civo --config staging.civo.json database backups ls postgres-demo | ||
❯ ./civo --config staging.civo.json database backups ls mysql-demo | ||
``` | ||
|
||
## PostgreSQL | ||
|
||
### Create Scheduled Backup | ||
|
||
```bash | ||
❯ ./civo --config staging.civo.json database backups create postgres-demo --name every10minutes --schedule "*/10 * * * *" | ||
Database backup (every10minutes) for database postgr-b697-c429d7 has been created | ||
``` | ||
|
||
### List backup | ||
|
||
```bash | ||
Scheduled backup | ||
+-------------+---------------+------------+--------------+----------------+------------------+ | ||
| Database ID | Database Name | Software | Schedule | Backup Name | Backup | | ||
+-------------+---------------+------------+--------------+----------------+------------------+ | ||
| 65dd81 | postgres-demo | PostgreSQL | */10 * * * * | every10minutes | 20240131-100009F | | ||
+-------------+---------------+------------+--------------+----------------+------------------+ | ||
``` | ||
|
||
### Create Manual Backup | ||
|
||
```bash | ||
❯ ./civo --config staging.civo.json database backups create postgres-demo | ||
``` | ||
|
||
### List | ||
|
||
```bash | ||
❯ ./civo --config staging.civo.json database backups ls postgres-demo | ||
Scheduled backup | ||
+-------------+---------------+------------+--------------+----------------+------------------+ | ||
| Database ID | Database Name | Software | Schedule | Backup Name | Backup | | ||
+-------------+---------------+------------+--------------+----------------+------------------+ | ||
| 65dd81 | postgres-demo | PostgreSQL | */10 * * * * | every10minutes | 20240131-100009F | | ||
+-------------+---------------+------------+--------------+----------------+------------------+ | ||
Manual backups | ||
+-------------+---------------+------------+------------------+ | ||
| Database ID | Database Name | Software | Backup | | ||
+-------------+---------------+------------+------------------+ | ||
| 65dd81 | postgres-demo | PostgreSQL | 20240131-095615F | | ||
+-------------+---------------+------------+------------------+ | ||
``` | ||
|
||
### Restore from scheduled | ||
|
||
```bash | ||
❯ ./civo --config staging.civo.json database restore postgres-demo --name restorefromscheduledbackup --backup 20240131-102006F | ||
Warning: Are you sure you want to restore db postgres-demo from 20240131-102006F backup (y/N) ? y | ||
Restoring database postgres-demo from from backup 20240131-102006F | ||
``` | ||
|
||
### Restore from manual | ||
|
||
```bash | ||
❯ ./civo --config staging.civo.json database restore postgres-demo --name restorefromscheduledbackup --backup 20240131-095615F | ||
Warning: Are you sure you want to restore db postgres-demo from 20240131-095615F backup (y/N) ? y | ||
Restoring database postgres-demo from from backup 20240131-095615F | ||
``` | ||
|
||
## MySQL Backup | ||
|
||
### Create | ||
|
||
```bash | ||
❯ ./civo --config staging.civo.json database backups create mysql-demo --name firstbackup --type manual | ||
Database backup (firstbackup) for database mysql-demo has been created | ||
``` | ||
|
||
### List backup | ||
|
||
```bash | ||
❯ ./civo --config staging.civo.json database backups ls mysql-demo | ||
Manual backups | ||
+-------------+---------------+-----------+-------------+----------+--------+ | ||
| Database ID | Database Name | Backup ID | Backup Name | Software | Status | | ||
+-------------+---------------+-----------+-------------+----------+--------+ | ||
| 0d328d | mysql-demo | ba0466 | firstbackup | MySQL | READY | | ||
+-------------+---------------+-----------+-------------+----------+--------+ | ||
``` | ||
|
||
### Restore | ||
|
||
```bash | ||
❯ ./civo --config staging.civo.json database restore mysql-demo --name restorefirstbackup --backup firstbackup | ||
Warning: Are you sure you want to restore db mysql-demo from firstbackup backup (y/N) ? y | ||
Restoring database mysql-demo from from backup firstbackup | ||
``` |