๐พ Backing Up and Restoring Databases in Sybase ASE
Backing up and restoring in Sybase ASE (Adaptive Server Enterprise) uses the dump and load commands. It's straightforward once you're familiar with the basics — here's a practical guide.
๐ Why Backups Matter
Regular backups protect you from:
-
Data loss (hardware failure, corruption, mistakes)
-
System crashes
-
Application rollbacks or refreshes
๐งฑ Step 1: Full Database Backup (Dump)
To take a full backup, use the dump database command. Here's how:
-- Full backup of the database
dump database mydatabase
to "/sybase/backups/mydatabase_full.bak"
๐ Tip: Use meaningful file names, e.g., include dates like
mydatabase_2025_05_29.bak.
You can also use a tape device or a backup server if you have one configured.
๐งช Step 2: Transaction Log Backup (Optional)
If your database is in full recovery mode, you can also back up the transaction log:
dump transaction mydatabase
to "/sybase/backups/mydatabase_log_2025_05_29.trn"
๐ก Frequent log backups reduce recovery time and free up log space.
♻️ Step 3: Restore the Database (Load)
To restore the full backup:
-- Load full backup
load database mydatabase
from "/sybase/backups/mydatabase_full.bak"
If you are restoring to a new server, make sure to disk init the devices first, or map them with with move if needed.
๐ Step 4: Restore Transaction Logs (If Using Them)
load transaction mydatabase
from "/sybase/backups/mydatabase_log_2025_05_29.trn"
You can repeat this step for each log backup you have.
๐ Step 5: Bring the Database Online
After all loads are complete, bring the database online:
✅ Summary
| Task | Command |
|---|---|
| Full Backup | dump database |
| Transaction Log Backup | dump transaction |
| Restore Full Backup | load database |
| Restore Log Backup | load transaction |
| Online the Database | online database |
๐ Sample Backup Script
-- Full backup
dump database mydatabase to "/sybase/backups/mydatabase_full_2025_05_29.bak"
-- Log backup
dump transaction mydatabase to "/sybase/backups/mydatabase_log_2025_05_29.trn"
๐ Sample Restore Script
-- Full restore
load database mydatabase from "/sybase/backups/mydatabase_full_2025_05_29.bak"
-- (Optional) Restore log
load transaction mydatabase from "/sybase/backups/mydatabase_log_2025_05_29.trn"
-- Bring online
online database mydatabase
Comments
Post a Comment