diff --git a/docs/database-operations/_category_.json b/docs/database-operations/_category_.json new file mode 100644 index 0000000..46d0d8b --- /dev/null +++ b/docs/database-operations/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "Database Operations", + "position": 4, + "link": { + "type": "generated-index", + "description": "Guides for managing SQL Server databases, including backup, restore, and recovery operations." + } +} diff --git a/docs/database-operations/sql-server-backup-restore/_category_.json b/docs/database-operations/sql-server-backup-restore/_category_.json new file mode 100644 index 0000000..ebbd14c --- /dev/null +++ b/docs/database-operations/sql-server-backup-restore/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "Backup & Restore Guide", + "position": 1, + "link": { + "type": "generated-index", + "description": "Step-by-step guide for backing up and restoring SQL Server databases using SSMS." + } +} diff --git a/docs/database-operations/sql-server-backup-restore/backing-up.md b/docs/database-operations/sql-server-backup-restore/backing-up.md new file mode 100644 index 0000000..7b966ec --- /dev/null +++ b/docs/database-operations/sql-server-backup-restore/backing-up.md @@ -0,0 +1,102 @@ +--- +sidebar_position: 2 +title: "Backing Up a Database" +--- + +# Backing Up a Database + +--- + +Before performing a backup, choose the right type for your situation: + +| Type | **What it captures** | **When to use** | +| ------------------- | ------------------------------------------ | ----------------------------------------------- | +| **Full** | The entire database | Weekly baseline; required before any other type | +| **Differential** | Changes since the last full backup | Daily; faster and lighter than a full backup | +| **Transaction Log** | All log activity since the last log backup | Hourly or more; enables point-in-time recovery | + +--- + +## Full Backup + +1. Open SSMS and connect to your SQL Server instance. +2. In the **Object Explorer** panel, expand the **Databases** node. +3. Right-click the database you want to back up, then select **Tasks → Back Up…** + +![SSMS Backup Menu](img/1.png) + +4. The **Back Up Database** window will open. Under **Backup type**, make sure **Full** is selected. + +![Backup Type Full](img/2.png) + +5. Under **Destination**, you will see a default backup path. To change it: + 1. Click **Remove** to clear the existing path. + 2. Click **Add**, then type or browse to your desired folder and filename (e.g., `MyDatabase_Full_2025-04-22.bak`). + 3. Click **OK**. + +![Backup Destination](img/3.png) + +6. Click **OK** to start the backup. + +![Start Backup](img/4.png) + +7. A confirmation dialog will appear when it completes successfully. + +![Backup Success](img/5.png) + +--- + +## Differential Backup + +Follow the same steps as a full backup, with one change at step 4: under **Backup type**, select **Differential** instead of Full. + +![Backup Type Differential](img/6.png) + +**NOTE:** A differential backup requires that a full backup has already been taken for the same database. + +--- + +## Transaction Log Backup + +1. Right-click the database **→ Tasks → Back Up…** +2. Under **Backup type**, select **Transaction Log**. +3. Set the destination path and filename (e.g., `MyDatabase_Log_2025-04-22_10h00.trn`). + +![Backup Type Transaction Log](img/7.png) + +4. Click **OK** to run the backup. + +![Start Log Backup](img/8.png) + +**NOTE:** This option is only available when the database uses the **Full** or **Bulk-Logged** recovery model. To verify: right-click your database **→ Properties → Options →** check the **Recovery model** field. + +![Check Recovery Model](img/9.png) + +--- + +## Scheduling Automatic Backups + +You can automate recurring backups directly from the backup window without any scripting: +1. Configure your backup as described in the steps above, but **do not click OK yet**. + +![Configure Backup](img/10.png) + +2. At the top of the window, click **Script → Script Action to Job** + +![Script to Job](img/11.png) + +3. The **New Job** window will open. Go to the **Schedules** page and click **New**. + +![New Schedule](img/12.png) + +4. Define your schedule (frequency, start time, recurrence) and click **OK**. + +![Define Schedule](img/13.png) + +5. Click **OK** again to save the job. SQL Server Agent will run the backup automatically on the defined schedule. + +![Save Job](img/14.png) + +**NOTE:** SQL Server Agent must be running for scheduled jobs to execute. You can check its status in Object Explorer (it appears as a node at the bottom of the tree). + +![SQL Server Agent Status](img/15.png) diff --git a/docs/database-operations/sql-server-backup-restore/img/1.png b/docs/database-operations/sql-server-backup-restore/img/1.png new file mode 100644 index 0000000..efa52af Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/1.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/10.png b/docs/database-operations/sql-server-backup-restore/img/10.png new file mode 100644 index 0000000..1647139 Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/10.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/11.png b/docs/database-operations/sql-server-backup-restore/img/11.png new file mode 100644 index 0000000..5322adf Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/11.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/12.png b/docs/database-operations/sql-server-backup-restore/img/12.png new file mode 100644 index 0000000..7c7b2ef Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/12.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/13.png b/docs/database-operations/sql-server-backup-restore/img/13.png new file mode 100644 index 0000000..e07a21d Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/13.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/14.png b/docs/database-operations/sql-server-backup-restore/img/14.png new file mode 100644 index 0000000..dc2588c Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/14.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/15.png b/docs/database-operations/sql-server-backup-restore/img/15.png new file mode 100644 index 0000000..0d733a2 Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/15.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/16.png b/docs/database-operations/sql-server-backup-restore/img/16.png new file mode 100644 index 0000000..67712ce Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/16.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/17.png b/docs/database-operations/sql-server-backup-restore/img/17.png new file mode 100644 index 0000000..7d9d843 Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/17.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/18.png b/docs/database-operations/sql-server-backup-restore/img/18.png new file mode 100644 index 0000000..afb8314 Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/18.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/19.png b/docs/database-operations/sql-server-backup-restore/img/19.png new file mode 100644 index 0000000..3e1466a Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/19.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/2.png b/docs/database-operations/sql-server-backup-restore/img/2.png new file mode 100644 index 0000000..d1b56dc Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/2.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/20.png b/docs/database-operations/sql-server-backup-restore/img/20.png new file mode 100644 index 0000000..d21af3b Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/20.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/21.png b/docs/database-operations/sql-server-backup-restore/img/21.png new file mode 100644 index 0000000..132b21e Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/21.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/22.png b/docs/database-operations/sql-server-backup-restore/img/22.png new file mode 100644 index 0000000..9fd171a Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/22.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/23.png b/docs/database-operations/sql-server-backup-restore/img/23.png new file mode 100644 index 0000000..8e34682 Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/23.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/24.png b/docs/database-operations/sql-server-backup-restore/img/24.png new file mode 100644 index 0000000..9b3735d Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/24.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/25.png b/docs/database-operations/sql-server-backup-restore/img/25.png new file mode 100644 index 0000000..a897bff Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/25.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/26.png b/docs/database-operations/sql-server-backup-restore/img/26.png new file mode 100644 index 0000000..b1049b5 Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/26.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/27.png b/docs/database-operations/sql-server-backup-restore/img/27.png new file mode 100644 index 0000000..6491150 Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/27.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/28.png b/docs/database-operations/sql-server-backup-restore/img/28.png new file mode 100644 index 0000000..7f2ffa1 Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/28.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/3.png b/docs/database-operations/sql-server-backup-restore/img/3.png new file mode 100644 index 0000000..ae105b6 Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/3.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/4.png b/docs/database-operations/sql-server-backup-restore/img/4.png new file mode 100644 index 0000000..10055bd Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/4.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/5.png b/docs/database-operations/sql-server-backup-restore/img/5.png new file mode 100644 index 0000000..395063c Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/5.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/6.png b/docs/database-operations/sql-server-backup-restore/img/6.png new file mode 100644 index 0000000..b8d24a4 Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/6.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/7.png b/docs/database-operations/sql-server-backup-restore/img/7.png new file mode 100644 index 0000000..c11b821 Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/7.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/8.png b/docs/database-operations/sql-server-backup-restore/img/8.png new file mode 100644 index 0000000..0039fa5 Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/8.png differ diff --git a/docs/database-operations/sql-server-backup-restore/img/9.png b/docs/database-operations/sql-server-backup-restore/img/9.png new file mode 100644 index 0000000..e51f50a Binary files /dev/null and b/docs/database-operations/sql-server-backup-restore/img/9.png differ diff --git a/docs/database-operations/sql-server-backup-restore/index.md b/docs/database-operations/sql-server-backup-restore/index.md new file mode 100644 index 0000000..4184807 --- /dev/null +++ b/docs/database-operations/sql-server-backup-restore/index.md @@ -0,0 +1,12 @@ +--- +sidebar_position: 1 +title: "Overview" +--- + +# Overview + +--- + +SQL Server Management Studio (SSMS) is the official graphical tool for managing SQL Server. This guide walks through how to back up and restore a database entirely through its interface, with no scripting required. + +All backup and restore operations in this guide produce or consume `.bak` files, which is SQL Server's native backup format. diff --git a/docs/database-operations/sql-server-backup-restore/reference.md b/docs/database-operations/sql-server-backup-restore/reference.md new file mode 100644 index 0000000..826f197 --- /dev/null +++ b/docs/database-operations/sql-server-backup-restore/reference.md @@ -0,0 +1,29 @@ +--- +sidebar_position: 4 +title: "Reference" +--- + +# Reference + +--- + +## Required Permissions + +| **Operation** | **Required Role** | +| ------------- | ------------------------------------------------ | +| Backup | `db_backupoperator` database role, or `sysadmin` | +| Restore | `sysadmin` or `dbcreator` server role | + +--- + +## Quick Reference + +| Task | SSMS Path | +| -------------------------- | -------------------------------------------------------- | +| Full backup | Right-click DB → Tasks → Back Up → Type: Full | +| Differential backup | Right-click DB → Tasks → Back Up → Type: Differential | +| Transaction log backup | Right-click DB → Tasks → Back Up → Type: Transaction Log | +| Schedule a backup | In the Back Up window → Script → Script Action to Job | +| Restore a database | Right-click Databases → Restore Database | +| Point-in-time restore | Restore Database → General → Timeline… | +| Restore to new name/server | Restore Database → General (rename) + Files (relocate) | diff --git a/docs/database-operations/sql-server-backup-restore/restoring.md b/docs/database-operations/sql-server-backup-restore/restoring.md new file mode 100644 index 0000000..7f0ac22 --- /dev/null +++ b/docs/database-operations/sql-server-backup-restore/restoring.md @@ -0,0 +1,93 @@ +--- +sidebar_position: 3 +title: "Restoring a Database" +--- + +# Restoring a Database + +--- + +**WARNING:** Restoring a database **replaces its current contents**. Always confirm you are targeting the correct server and database before proceeding. Close any active connections to the target database beforehand. + +--- + +## Restore from a Full Backup + +1. In **Object Explorer**, right-click the **Databases** node (not a specific database) and select **Restore Database…** + +![SSMS Restore Menu](img/16.png) + +2. The **Restore Database** window opens on the **General** page. Under **Source**, select **Device**, then click the … (Browse) button. + +![Restore Source Device](img/17.png) + +3. In the **Select backup devices** dialog, click **Add**. + +![Add Backup Device](img/18.png) + +4. Navigate to your `.bak` file, select it, and click **OK**. Then click **OK** again to close the dialog. + +![Select BAK File](img/19.png) + +5. The backup details will populate in the **Backup sets to restore** grid. Verify that the correct backup is checked. +6. Under **Destination**, confirm the database name in the **Database** field. You can type a new name here to restore as a different database. + +![Verify Restore Sets](img/20.png) + +7. Go to the **Options** page (left-hand panel). Check **Close existing connections to the destination database** to avoid connection conflicts during restore. +8. Click **OK** to begin. + +![Restore Options](img/21.png) + +9. A confirmation message will appear on success. + +![Restore Success](img/22.png) + +--- + +## Restore from a Full + Differential Backup + +1. Follow steps 1–4 above, but when adding backup devices, add **both** the full backup file and the differential backup file. + +![Add Multiple Backup Devices](img/23.png) + +2. SSMS will automatically detect the backup types and display them in the correct order in the **Backup sets to restore** grid. +3. Make sure **both** the full and differential entries are checked. + +![Multiple Restore Sets](img/24.png) + +4. Go to **Options**, check **Close existing connections to the destination database**. +5. Click **OK** to restore. + +--- + +## Point-in-Time Recovery (Transaction Logs) + +1. Follow steps 1–4 above, adding the full backup file **and all transaction log** (`.trn`) files in the **Select backup devices** dialog. + +![Add Log Files](img/25.png) + +2. SSMS will list all backup sets in the correct sequence in the grid. Verify all needed entries are checked. +3. To restore to a specific point in time, click the **Timeline…** button at the top of the **General** page. In the **Backup Timeline** dialog, drag the slider or type a specific date and time, then click **OK**. + +![Restore Timeline](img/26.png) + +4. Go to **Options**, check **Close existing connections to the destination database**. +5. Click **OK** to run the restore. + +--- + +## Restoring to a Different Server or Name + +To restore a backup onto a different server, or under a different database name: +1. Connect SSMS to the **target server** (not the original one). +2. Follow the restore steps in the section above. +3. At step 6, change the **Database** name field to your desired new name. + +![Rename Database](img/27.png) + +4. Go to the **Files** page (left-hand panel). You will see the original file paths listed. Check **Relocate all files to folder** and specify the data and log folders on the target server. + +![Relocate Files](img/28.png) + +5. Click **OK** to restore. diff --git a/src/pages/index.js b/src/pages/index.js index 498627c..c191ef4 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -24,6 +24,12 @@ const categories = [ description: 'Master Git operations across different tools like Apache NetBeans, JetBrains IDEs, and the Command-Line.', link: '/docs/category/git-operations', }, + { + title: 'Database Operations', + icon: '🗄️', + description: 'Guides for managing SQL Server databases, including backup, restore, and advanced recovery operations.', + link: '/docs/category/database-operations', + }, ]; function CategoryCard({title, icon, description, link}) {