This application provides a robust backup solution with the following features:
- Multiple backup sources and destinations
- Support for local, CIFS, NFS, and SMB protocols
- Manual and scheduled backups
- Detailed backup history and reporting
- Responsive design for both desktop and mobile devices
# Pentru suport CIFS/SMB
sudo apt install cifs-utils
# Pentru suport NFS
sudo apt install nfs-common
# Pentru rsync
sudo apt install rsync
- Go 1.16 or higher
- Rsync (for file copying)
- Mount commands for CIFS/SMB and NFS
go mod init go-backup
# Install Go dependencies
go get github.com/gorilla/mux
go get github.com/go-co-op/gocron
Create the following directory structure:
go-backup/
├── main.go
├── static/
│ ├── index.html
│ ├── css/
│ │ └── styles.css
│ └── js/
│ └── app.js
Copy the provided files to their respective locations:
main.go
to the root directoryindex.html
to thestatic/
directorystyles.css
to thestatic/css/
directoryapp.js
to thestatic/js/
directory
# Navigate to the application directory
cd go-backup
# Build the application
go build -o go-backup
# Run the application
./go-backup
The application will now be accessible at http://localhost:8080
The dashboard provides an overview of your backup configurations and recent backup history. You can see:
- Total number of backup configurations
- Total completed backups
- Next scheduled backup
- Recent backup results
In this section, you can manage your backup configurations:
-
Create a new configuration:
- Click "New Configuration" button
- Fill in the required details:
- Name: A descriptive name for the backup
- Source Paths: One or more directories to backup
- Protocol: Local, CIFS, NFS, or SMB
- Destination Path: Where to store the backup
- Credentials (if using network protocols)
- Schedule (optional): Days and time for automatic backups
-
Edit an existing configuration:
- Click the edit icon next to a configuration
- Modify the settings as needed
- Click "Save Configuration"
-
Run a backup manually:
- Click the play icon next to a configuration
- Confirm to start the backup process
- The application will switch to the Results view to show progress
-
Delete a configuration:
- Click the trash icon next to a configuration
- Confirm deletion
The Results view shows the history of all backup operations:
- Filter by configuration or status
- View details of each backup including:
- Start and end times
- Duration
- Number of files backed up
- Total size
- Success or failure status
- Detailed messages (especially useful for troubleshooting failed backups)
-
Network Protocol Errors:
- Ensure the destination server is accessible
- Verify username and password
- Check if the necessary client tools are installed (e.g., cifs-utils for SMB/CIFS)
-
Permission Issues:
- The application needs sufficient permissions to read source files and write to destinations
- For network protocols, ensure the user has appropriate access rights
-
Scheduling Problems:
- Verify that at least one day of the week is selected
- Ensure the time is set correctly
The application logs to standard output. Run with output redirection to save logs:
./go-backup > backup.log 2>&1
The application is fully responsive and works on mobile devices:
- The navigation menu collapses to a hamburger menu on small screens
- Tables become scrollable to accommodate smaller displays
- Form fields adjust to fit the screen width
- Passwords are stored in plain text in the configuration file. Consider:
- Restricting file permissions on the configuration file
- Running the application in a secure environment
- Using a credential manager for production environments
Create a systemd service file:
sudo nano /etc/systemd/system/go-backup.service
Add the following content:
[Unit]
Description=Go Backup Application
After=network.target
[Service]
Type=simple
User=yourusername
WorkingDirectory=/path/to/go-backup
ExecStart=/path/to/go-backup/go-backup
Restart=on-failure
[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl enable go-backup
sudo systemctl start go-backup
Create a startup script or use Task Scheduler to run the application at system startup.