Enhanced logging in backup-logic.sh for better debugging, updated documentation in readme.md, and ensured log rotation in manifest.jps.

main
Anthony 2025-01-04 00:39:04 +08:00
parent aa7c89d3c9
commit df8ab1cce8
1 changed files with 47 additions and 0 deletions

View File

@ -96,21 +96,68 @@ bash /home/litespeed/mb-backups/backup_all.sh
sudo systemctl start crond sudo systemctl start crond
sudo systemctl enable crond sudo systemctl enable crond
``` ```
- To check the status of the cron service, you can run:
```bash
systemctl status crond
```
- If the service fails to start, check the system logs for any error messages related to cron:
```bash
journalctl -xe | grep crond
```
2. **Log Files**: 2. **Log Files**:
- Check the log files located in `/home/litespeed/mb-backups/logs/auto` for any errors or issues during backup operations. - Check the log files located in `/home/litespeed/mb-backups/logs/auto` for any errors or issues during backup operations.
- Each backup run generates a log file with a timestamp, which can help identify when issues occurred.
3. **Restic Issues**: 3. **Restic Issues**:
- Ensure that Restic is installed and configured correctly. You can verify its installation by running: - Ensure that Restic is installed and configured correctly. You can verify its installation by running:
```bash ```bash
restic version restic version
``` ```
- If you encounter issues with Restic, check the Restic logs for detailed error messages. You can enable verbose logging by adding the `-v` flag to your Restic commands.
4. **Backup Failures**: 4. **Backup Failures**:
- If a backup fails, check the corresponding log file for detailed error messages. The logs are typically located in `/var/log/backup_addon.log`. - If a backup fails, check the corresponding log file for detailed error messages. The logs are typically located in `/var/log/backup_addon.log`.
- Look for specific error messages that indicate what went wrong during the backup process.
5. **Cron Job Not Found**: 5. **Cron Job Not Found**:
- If the scheduled cron job is not found, ensure that the `manage_backup_schedule.sh` script was executed successfully and that the cron job was added correctly. - If the scheduled cron job is not found, ensure that the `manage_backup_schedule.sh` script was executed successfully and that the cron job was added correctly.
- You can list the current cron jobs by running:
```bash
crontab -l
```
- If the job is missing, re-run the `manage_backup_schedule.sh` script with the correct parameters.
6. **Debugging Cron Jobs**:
- If your cron job is not executing as expected, you can redirect the output and error messages to a log file by modifying the cron command in the `manage_backup_schedule.sh` script. For example:
```bash
CMD="RESTIC_PASSWORD=\"$3\" $BACKUP_SCRIPT > \"${BACKUP_LOG_PREFIX}\$(date +\\%Y-\\%m-\\%d_\\%H-\\%M-\\%S).log\" 2>&1"
```
- This will help capture any errors that occur when the cron job runs.
7. **Environment Variables**:
- Ensure that any environment variables required by your scripts (like `RESTIC_PASSWORD`) are set correctly. You can check the environment variables in your cron jobs by adding a command to print them to a log file:
```bash
env > /home/litespeed/mb-backups/logs/cron_env.log
```
8. **Permissions**:
- Ensure that the scripts have the correct permissions to execute. You can set the executable permission using:
```bash
chmod +x /home/litespeed/mb-backups/*.sh
```
9. **Testing Scripts Manually**:
- If you suspect an issue with a specific script, try running it manually in the terminal to see if it executes without errors. This can help isolate the problem.
10. **Check for Running Processes**:
- If you suspect that a backup process is already running, you can check for running instances of your backup scripts using:
```bash
pgrep -f backup_all.sh
```
- This will show you if there are any active processes related to your backup operations.
By following these debugging tips, you can effectively troubleshoot issues related to the MB Backup Manager and ensure that your backup processes run smoothly.
## Conclusion ## Conclusion