mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 04:30:13 -08:00
feat: Enhance crontab backup process with structured backup system and fallback mechanism
This commit is contained in:
1
crontab-backups/racknerd/current-crontab.backup
Normal file
1
crontab-backups/racknerd/current-crontab.backup
Normal file
@@ -0,0 +1 @@
|
||||
0 0 * * * { echo "Starting Docker backup"; /home/acedanger/shell/backup-docker.sh; echo "Docker backup completed with exit code: $?"; } 2>&1 | logger -t docker-backup -p user.info
|
||||
@@ -39,11 +39,31 @@ log_info() {
|
||||
}
|
||||
|
||||
backup_current_crontab() {
|
||||
log_info "Backing up current root crontab to $BACKUP_CRONTAB_FILE"
|
||||
if sudo crontab -l > "$BACKUP_CRONTAB_FILE" 2>/dev/null; then
|
||||
log_success "Current crontab backed up successfully"
|
||||
log_info "Creating structured backup using crontab-backup-system for host: $HOSTNAME"
|
||||
|
||||
# Use the comprehensive backup system
|
||||
if [ -f "$SCRIPT_DIR/crontab-backup-system.sh" ]; then
|
||||
if "$SCRIPT_DIR/crontab-backup-system.sh" backup manual; then
|
||||
log_success "Structured crontab backup created successfully"
|
||||
else
|
||||
log_warning "Structured backup failed, falling back to temporary backup"
|
||||
# Fallback to simple backup
|
||||
log_info "Backing up current root crontab to $BACKUP_CRONTAB_FILE"
|
||||
if sudo crontab -l > "$BACKUP_CRONTAB_FILE" 2>/dev/null; then
|
||||
log_success "Temporary backup created successfully"
|
||||
else
|
||||
log_warning "No existing crontab found or backup failed"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
log_warning "No existing crontab found or backup failed"
|
||||
log_warning "crontab-backup-system.sh not found, using temporary backup"
|
||||
# Fallback to simple backup
|
||||
log_info "Backing up current root crontab to $BACKUP_CRONTAB_FILE"
|
||||
if sudo crontab -l > "$BACKUP_CRONTAB_FILE" 2>/dev/null; then
|
||||
log_success "Temporary backup created successfully"
|
||||
else
|
||||
log_warning "No existing crontab found or backup failed"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user