A full-stack application built with .NET 8 and Angular 17 to automatically back up PostgreSQL databases. It performs scheduled backups using a cron expression and logs the backup history using Entity Framework Core. The application includes a simple dashboard for viewing the status of backups.
The application is built using the following technologies:
- Frontend: Angular 17
- Backend: .NET 8
- Task Scheduling: Quartz.NET
- ORM: Entity Framework Core
- Database: PostgreSQL
- IDE: Visual Studio
- Scheduled automatic backups of PostgreSQL databases
- Backup history tracking and logging in PostgreSQL
- Basic dashboard for managing backups
- Detailed error handling and logging for robust operation
Before running this application, make sure you have the following installed:
- Node.js
- .NET SDK (8.0)
- PostgreSQL
- Angular CLI (
npm install -g @angular/cli
)
- Clone the Repository
git clone https://github.com/Hukasx0/dotnet-angular-postgres-backup-tool.git
cd dotnet-angular-postgres-backup-tool
- Create a PostgreSQL database: Open your PostgreSQL client and run the following SQL command to create the required database:
CREATE DATABASE PgBackupToolDb;
- Configure the Connection String and Backup Settings Open the appsettings.json file located in dotnet-angular-postgres-backup-tool.Server/ and update the configuration with your PostgreSQL credentials and backup settings:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DatabaseConnection": "Host=localhost;Port=5432;Database=PgBackupToolDb;Username=postgres;Password=root"
},
"BackupSettings": {
"DbName": "PgBackupToolDb",
"Path": "C:\\PgBackups",
"PostgresPassword": "root",
"CronSchedule": "0 0 */3 * * ?"
}
}
- DatabaseConnection: The primary connection string for accessing your PostgreSQL instance.
- DbName: The name of the database to back up.
- Path: Directory where backups will be stored.
- PostgresPassword: Password for your PostgreSQL user.
- CronSchedule: Specifies how frequently backups are performed. The default value ("0 0 */3 * * ?") schedules a backup every 3 hours. You can modify this cron expression as needed.
Note: The CronSchedule setting uses Quartz.NET's cron syntax. Quartz Cron Expression Generator can help you customize the schedule.
- Navigate to the Server Directory
cd dotnet-angular-postgres-backup-tool.Server/
- Run migrations
Use Entity Framework Core to apply migrations and set up the database schema:
dotnet ef database update
- Start the API Server:
dotnet run
The backend API will start and should be accessible at https://localhost:5087.
- Navigate to the Angular project directory:
dotnet-angular-postgres-backup-tool.client/
- Install Angular Dependencies
Run the following command to install all required Node.js packages:
npm install
- Start the Angular application:
ng serve
The application will be available at http://localhost:4200
- Navigate to the Test Project Directory
Go to the test directory for the .NET backend:
cd ServerTest/
- Run Tests
Execute all backend unit and integration tests using the following command:
dotnet test
- Navigate to the Client Directory
Ensure you are in the Angular project directory:
cd dotnet-angular-postgres-backup-tool.client/
- Run Angular Tests
Use Angular's testing tool (Karma) to run all frontend tests:
ng test
dotnet-angular-postgres-backup-tool/
├── dotnet-angular-postgres-backup-tool.Server/ # .NET Backend
├── dotnet-angular-postgres-backup-tool.client/ # Angular Frontend
├── ServerTest/ # Xunit Tests for .NET backend
├── .gitignore
├── README.md
├── screenshot.png # Project screenshot
└── dotnet-angular-postgres-backup-tool.sln # Visual Studio Solution File