{"id":29040364,"url":"https://github.com/msalali/sql-server-advanced-backup","last_synced_at":"2026-05-10T03:04:22.150Z","repository":{"id":296695422,"uuid":"994169257","full_name":"Msalali/SQL-Server-Advanced-backup","owner":"Msalali","description":"Advanced Backup DataBase Using PowerShell Script","archived":false,"fork":false,"pushed_at":"2025-06-23T21:13:52.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-26T14:05:09.360Z","etag":null,"topics":["backup","database","database-management","dba","logfile","management","powershell","script","sql","sql-server","tools","utility"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Msalali.png","metadata":{"files":{"readme":"ReadME.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-01T11:17:14.000Z","updated_at":"2025-06-23T21:13:55.000Z","dependencies_parsed_at":"2025-06-01T20:25:17.342Z","dependency_job_id":"11897408-bb42-4c40-afff-bc681345578e","html_url":"https://github.com/Msalali/SQL-Server-Advanced-backup","commit_stats":null,"previous_names":["msalali/sql-server-advanced-backup"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Msalali/SQL-Server-Advanced-backup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Msalali%2FSQL-Server-Advanced-backup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Msalali%2FSQL-Server-Advanced-backup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Msalali%2FSQL-Server-Advanced-backup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Msalali%2FSQL-Server-Advanced-backup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Msalali","download_url":"https://codeload.github.com/Msalali/SQL-Server-Advanced-backup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Msalali%2FSQL-Server-Advanced-backup/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262081117,"owners_count":23255662,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","database","database-management","dba","logfile","management","powershell","script","sql","sql-server","tools","utility"],"created_at":"2025-06-26T14:05:02.366Z","updated_at":"2026-05-10T03:04:17.110Z","avatar_url":"https://github.com/Msalali.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SQL Server Backup \u0026 LogFile Script\n\nPowerShell script to **backup a SQL Server database**, generate a **LogFile of database size and objects**, verify the backup, and export a **log file** with detailed information.\n\n## 📋 Features\n\n- Connects to SQL Server using **Windows Authentication** or **SQL Server Login**.\n- Executes the stored procedure `ReportBackup` to collect database object sizes.\n- Creates a `.bak` backup file of the specified database.\n- Verifies backup integrity using `RESTORE VERIFYONLY`.\n- Generates a log file (`.txt`) containing:\n  - SQL Server version, edition, and level\n  - Object size LogFile (tables, indexes, total size, etc.)\n  - Backup status, size, and verification result\n- Automatically installs the `SqlServer` PowerShell module if it's not already available.\n\n---\n\n## 🛠️ How to Use\n\n### 1. Open PowerShell as Administrator\n\n(Optional but recommended for module installation)\n\nSet execution policy for the session:\n\n```powershell\nSet-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force\n```\n\n### 2. Run the Script\n\nExecute the script:\n\n```powershell\nCD Path dirctory script\n.\\BackupScript.ps1\n```\n\nYou will be prompted to enter the following:\n\n- **Server Name** (e.g., `localhost`, `127.0.0.1`, or `ServerName\\Instance`)\n- **Database Name** to back up\n- **Backup Folder Path** (where `.bak` and `.txt` files will be saved)\n- **Authentication Method**: Press `Y` for Windows Authentication or `N` for SQL Login (will prompt for credentials)\n\n---\n\n## 📄 Output\n\nTwo files will be generated in the specified directory:\n\n1. **Database Backup File**  \n   Format: `YourDatabase_Backup_yyyyMMdd_HHmmss.bak`\n\n2. **Log LogFile File**  \n   Format: `LogFileBackup_YourDatabase_yyyyMMdd_HHmmss.txt`  \n   Includes:\n   - SQL Server details\n   - Table/index/object sizes\n   - Backup file size and verification status\n   - Timestamp and execution notes\n\n---\n\n## 📌 Requirements\n\n- PowerShell 5.1 or newer\n- `SqlServer` module (installed automatically if missing)\n- Stored Procedure `ReportBackup` must exist in the target database  \n\n\n---\n\n## ✅ Example Output in Log File\n\n```text\nSQL Server Info:-\n - Version        : 15.0.2000.5\n - Edition        : Developer Edition\n - Product Level  : RTM\n\n--------------------------------------------\nObjects Include:-\nDatabase_Name Date_Report Object_Name  Object_Type Count_Rows Size (MB)\n------------- ------------ ------------ ------------ ----------- ----------\nMyDB          2025-05-18   Customers     Table        100000     25.3\nMyDB          2025-05-18   Orders        Table        250000     47.9\nMyDB          2025-05-18   DB Total      DB Total     N/A        73.2\n\n--------------------------------------------\nBackup Info:-\n - Backup Date    : 2025-05-18 15:30:21\n - Backup Size    : 75.65 MB\n - Status         : Completed\n - Verify Status  : Passed\n\n--------------------------------------------\nDev Script By Meshary alali (:\n--------------------------------------------\n```\n\n\n\n---\n\n## 👨‍💻 Devloper\n\n****  \n\n [Meshary Alali](https://github.com/msalali)\n\n \n\n---\n\n\n\n\n# سكربت النسخ الاحتياطي المتقدم لقاعدة بيانات SQL Server\n\nسكريبت PowerShell يقوم بعمل **نسخة احتياطية لقاعدة بيانات SQL Server**، ويولّد **تقريرًا بحجم الكائنات داخل القاعدة**، ويتحقق من صحة النسخة، ويولّد **ملف سجل** يحتوي على كافة التفاصيل.\n\n## 📋 الميزات\n\n- الاتصال بـ SQL Server باستخدام **مصادقة ويندوز** أو **تسجيل دخول SQL Server**.\n- تنفيذ الإجراء المخزن `ReportBackup` لاستخراج أحجام الكائنات.\n- إنشاء ملف نسخة احتياطية بامتداد `.bak`.\n- التحقق من صحة النسخة الاحتياطية باستخدام `RESTORE VERIFYONLY`.\n- توليد ملف سجل (`.txt`) يحتوي على:\n  - إصدار SQL Server والمستوى والنوع\n  - تقرير تفصيلي عن الكائنات (جداول، فهارس، الحجم الإجمالي، ...)\n  - حالة النسخ وحجم الملف ونتيجة التحقق\n- تثبيت وحدة PowerShell `SqlServer` تلقائيًا في حال عدم توفرها.\n\n---\n\n## 🛠️ طريقة الاستخدام\n\n### 1. افتح PowerShell كمسؤول\n\n(اختياري لكن يُفضل لتفادي مشاكل التصاريح)\n\nقم بتعيين سياسة التنفيذ للجلسة:\n\n```powershell\nSet-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force\n```\n\n### 2. تشغيل السكربت\n\nقم بتشغيل السكربت:\n\n```powershell\nCD Path dirctory script\n.\\BackupScript.ps1\n\n```\n\nسيُطلب منك إدخال ما يلي:\n\n- **اسم الخادم** (مثل: `localhost` أو `127.0.0.1` أو `ServerName\\Instance`)\n- **اسم قاعدة البيانات** التي ترغب بعمل نسخة احتياطية لها\n- **مسار حفظ النسخة** (حيث سيتم حفظ ملفات `.bak` و`.txt`)\n- **طريقة المصادقة**: اضغط `Y` لاستخدام مصادقة ويندوز أو `N` لاستخدام تسجيل دخول SQL (وسيطلب منك بيانات الدخول)\n\n---\n\n## 📄 الملفات الناتجة\n\nيتم إنشاء ملفين في المسار الذي حددته:\n\n1. **ملف النسخة الاحتياطية**  \n   الصيغة: `YourDatabase_Backup_yyyyMMdd_HHmmss.bak`\n\n2. **ملف السجل النصي**  \n   الصيغة: `LogFileBackup_YourDatabase_yyyyMMdd_HHmmss.txt`  \n   يحتوي على:\n   - تفاصيل SQL Server\n   - تقرير حجم الكائنات\n   - حجم النسخة وحالة التحقق\n   - الوقت وتفاصيل التشغيل\n\n---\n\n## 📌 المتطلبات\n\n- PowerShell 5.1 أو أحدث\n- وحدة `SqlServer` (يتم تثبيتها تلقائيًا إن لم تكن متوفرة)\n- الإجراء المخزن `ReportBackup` يجب أن يكون موجودًا داخل قاعدة البيانات  \n\n---\n\n## ✅ مثال على الإخراج داخل ملف السجل\n\n```text\nSQL Server Info:-\n - Version        : 15.0.2000.5\n - Edition        : Developer Edition\n - Product Level  : RTM\n\n--------------------------------------------\nObjects Include:-\nDatabase_Name Date_Report Object_Name  Object_Type Count_Rows Size (MB)\n------------- ------------ ------------ ------------ ----------- ----------\nMyDB          2025-05-18   Customers     Table        100000     25.3\nMyDB          2025-05-18   Orders        Table        250000     47.9\nMyDB          2025-05-18   DB Total      DB Total     N/A        73.2\n\n--------------------------------------------\nBackup Info:-\n - Backup Date    : 2025-05-18 15:30:21\n - Backup Size    : 75.65 MB\n - Status         : Completed\n - Verify Status  : Passed\n\n--------------------------------------------\nDev Script By Meshary alali (:\n--------------------------------------------\n```\n\n---\n\n## 👨‍💻 المطور\n\n\n [مشاري العلي](https://github.com/msalali)\n\n\n\n---\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsalali%2Fsql-server-advanced-backup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsalali%2Fsql-server-advanced-backup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsalali%2Fsql-server-advanced-backup/lists"}