This application is a simple web interface for creating and downloading PostgreSQL database backups. It uses Express.js for the server, basic authentication for security, and environment variables for configuration.
- Basic authentication to secure access.
- Create PostgreSQL database backups.
- Download existing backup files.
- Delete backup files.
- Simple and clean user interface.
- Node.js and npm installed on your machine.
- PostgreSQL installed and accessible from your server.
- PostgreSQL client (e.g.,
psql
) installed on your machine. - A
.env
file with the necessary configuration.
To install the PostgreSQL client on your machine, follow these steps:
-
Using Homebrew:
brew install postgresql
-
Verify the installation:
psql --version
-
Update the package list:
sudo apt update
-
Install the PostgreSQL client:
sudo apt install postgresql-client
-
Verify the installation:
psql --version
-
Download the installer from the official PostgreSQL website: PostgreSQL Downloads
-
Run the installer and select the components you need, including the command line tools.
-
Verify the installation by opening a command prompt and typing:
psql --version
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory with the following content:POSTGRES_DATABASE_URL=postgres://<db_user>:<db_password>@<db_host>:<db_port>/<db_name> AUTH_USER=admin AUTH_PASSWORD=password123 PORT=3000
Replace
<db_user>
,<db_password>
,<db_host>
,<db_port>
, and<db_name>
with your actual PostgreSQL database credentials and connection details. -
Ensure the
backups
directory exists:Create a directory named
backups
in the root of your project if it doesn't already exist. This is where the backup files will be stored.mkdir backups
-
Start the application:
npm start
-
Access the application:
Open your web browser and go to
http://localhost:3000
. You will be prompted to enter the username and password specified in your.env
file. -
Create a backup:
Click the "Create Backup" button to generate a new PostgreSQL backup. The backup will be listed below the button once it's created.
-
Download a backup:
Click on any backup file listed to download it to your local machine.
-
Delete a backup:
To delete a backup, simply click the "Delete" button next to the backup file you wish to remove in the web interface. This will send a request to the server to delete the file from the backups directory.
Ensure the server is running and you have the necessary permissions to delete files from the server's file system.
- Ensure your
.env
file is added to.gitignore
to prevent it from being committed to version control. - Use strong passwords for your database and basic authentication.
This project is licensed under the MIT License. See the LICENSE file for details.