Guepard / Platform
Discarding Changes in Databases
Discover the methods to discard changes and restore databases in Guepard
Guepard provides multiple mechanisms to discard changes and restore a database to a previous state. Whether you're experimenting with data, testing new features, or recovering from unintended modifications, Guepard ensures flexibility and speed in reverting changes.
The primary methods available in Guepard are:
- Snapshots – Save and restore the full state of a database.
- Instant Rollback – Instantly discard all changes after a specific snapshot.
- Point-in-Time Recovery (PITR) for PostgreSQL – Restore a PostgreSQL database to a specific timestamp.
These features allow for safe experimentation and instant recovery, making database management more efficient.
1. Snapshots
A snapshot captures the entire state of a database at a specific point in time. This acts as a restore point that can be used to revert changes, clone environments, or protect against accidental modifications. Snapshots in Guepard are lightweight and efficient, leveraging the underlying storage system to store only the differences rather than duplicating data.
Just like taking a picture, snapshots capture the database's state, allowing you to restore it whenever needed. The process involves three key steps:
- Snapshot Creation – A snapshot is taken at a specific moment, saving all database data and metadata.
- Copy-on-Write Efficiency – Instead of duplicating the entire database, Guepard tracks changes, reducing storage costs.
- Fast Restoration – A snapshot can be restored instantly, replacing the current state with the saved version.
Snapshots are beneficial for various use cases, including:
- Pre-Deployment Safety – Take a snapshot before running a migration or update.
- Testing & Experimentation – Clone a database state for testing without affecting the original.
- Disaster Recovery – Restore a stable version after a failed operation.
How to Create a Snapshot in Guepard
- Navigate to the Guepard Console and select the database instance.
- Click on the Snapshots tab.
- Choose Create Snapshot, enter a name (optional), and confirm.
- The snapshot will be stored and available for restoration.
How to Restore a Snapshot
- Open the Snapshots tab in the Guepard Console.
- Select the snapshot you want to restore.
- Click Restore and confirm the action.
- The database will revert to the snapshot state instantly.
Tip: Guepard allows scheduled snapshots, enabling automatic backups at defined intervals.
2. Instant Discard
Instant rollback provides the fastest way to discard all changes after a specific snapshot. Unlike restoring a snapshot (which replaces the database state), rollback eliminates all changes made after the snapshot without affecting the storage structure.
This feature is particularly useful in development and testing environments, where quick resets are required after executing queries, tests, or experiments.
Performing an instant rollback in Guepard:
- Resets the database state to the last snapshot.
- All changes made after the snapshot are discarded.
- Happens instantly without downtime.
The instant rollback feature is beneficial for various scenarios, including:
- Undo Unwanted Changes – If a script introduces unexpected issues, rollback restores the last working state.
- Testing and Debugging – Developers can experiment freely and reset databases instantly.
- Data Integrity – Ensures that no unverified changes persist in a database.
How to Perform an Instant Rollback
- Open the Guepard Console and select your database.
- Go to the Snapshots Graph section.
- Choose the snapshot to rollback to.
- Click Rollback and confirm.
- The database will immediately revert, discarding all changes made after the snapshot.
Important: Rollback operations are irreversible. Ensure you want to discard all changes before confirming.
3. Point-in-Time Recovery (PITR) for PostgreSQL
Point-in-Time Recovery (PITR) is a feature available for PostgreSQL databases that allows restoring a database to a specific timestamp. This is particularly useful when recovering from accidental modifications, database corruption, or failed migrations. Unlike snapshots, PITR relies on continuous transaction logs, allowing for granular recovery at any point in time.
Essential features of PITR in PostgreSQL include:
- WAL Archiving – PostgreSQL continuously writes changes to Write-Ahead Logs (WAL).
- Backup & Recovery – Users can restore a database to any state recorded in WAL logs.
- Timestamp-Based Restoration – Instead of restoring a full snapshot, you specify an exact time for rollback.
PITR is beneficial for various scenarios, including:
- Recovering from human errors (e.g., accidental DELETE operations).
- Rolling back after failed migrations or schema changes.
- Fine-grained recovery for databases requiring high data integrity.
How to Perform a PITR in PostgreSQL
- Ensure WAL Archiving is Enabled by modifying
postgresql.conf:wal_level = replica archive_mode = on archive_command = 'cp %p /path/to/archive/%f' - Create a Base Backup using
pg_basebackup:pg_basebackup -D /path/to/backup -Fp -Xs -P -R - Restore the Database by stopping PostgreSQL and replacing the data directory with the backup:
rm -rf /var/lib/postgresql/data cp -R /path/to/backup /var/lib/postgresql/data - Configure Recovery by adding
recovery.conf:restore_command = 'cp /path/to/archive/%f %p' recovery_target_time = '2024-03-01 12:30:00' - Restart PostgreSQL, and it will recover to the specified timestamp.
Note: PITR requires prior configuration of WAL archiving and periodic backups. Ensure your system is set up before attempting a recovery.
Choosing the Right Method
| Feature | Purpose | Best For |
|---|---|---|
| Snapshots | Saves a database state | Creating restore points, cloning environments |
| Instant Rollback | Discards all changes after a snapshot | Fast resets, undoing modifications |
| PITR | Restores a PostgreSQL database to a timestamp | Granular recovery from accidental changes |
By integrating these recovery features, Guepard ensures data integrity, operational efficiency, and a seamless workflow for developers and businesses managing databases.