Fix: Service management errors in sigvild-gallery restoration
- Fix Unix timestamp conversion in restore.yml using proper strftime syntax - Add service existence check before stopping sigvild-gallery service - Fix systemd service template environment variable syntax error - Add proper error handling for fresh deployments where service doesn't exist yet Resolves service management failures during restoration on fresh VPS installations.
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
- name: Display found backup files
|
- name: Display found backup files
|
||||||
debug:
|
debug:
|
||||||
msg: "Found backup: {{ item.path }} ({{ (item.size / 1024 / 1024) | round(2) }}MB, {{ item.mtime | to_datetime }})"
|
msg: "Found backup: {{ item.path }} ({{ (item.size / 1024 / 1024) | round(2) }}MB, {{ '%Y-%m-%d %H:%M:%S' | strftime(item.mtime | int) }})"
|
||||||
loop: "{{ backup_files.files | sort(attribute='mtime') }}"
|
loop: "{{ backup_files.files | sort(attribute='mtime') }}"
|
||||||
when: backup_files.files | length > 0
|
when: backup_files.files | length > 0
|
||||||
|
|
||||||
@@ -33,6 +33,15 @@
|
|||||||
- existing_data.stat.exists
|
- existing_data.stat.exists
|
||||||
- backup_files.files | length > 0
|
- backup_files.files | length > 0
|
||||||
|
|
||||||
|
- name: Skip restore due to existing data
|
||||||
|
debug:
|
||||||
|
msg:
|
||||||
|
- "🛡️ SAFETY: Restore skipped to protect existing data"
|
||||||
|
- "Remove {{ sigvild_gallery_data_dir }}/data.db manually to enable restore"
|
||||||
|
when:
|
||||||
|
- existing_data.stat.exists
|
||||||
|
- backup_files.files | length > 0
|
||||||
|
|
||||||
- name: Restore from latest backup
|
- name: Restore from latest backup
|
||||||
block:
|
block:
|
||||||
- name: Get latest backup file
|
- name: Get latest backup file
|
||||||
@@ -45,12 +54,22 @@
|
|||||||
- "Restoring from latest backup: {{ latest_backup | basename }}"
|
- "Restoring from latest backup: {{ latest_backup | basename }}"
|
||||||
- "Target directory: {{ sigvild_gallery_data_dir }}"
|
- "Target directory: {{ sigvild_gallery_data_dir }}"
|
||||||
|
|
||||||
|
- name: Check if sigvild-gallery service exists
|
||||||
|
stat:
|
||||||
|
path: /etc/systemd/system/sigvild-gallery.service
|
||||||
|
register: sigvild_service_file
|
||||||
|
|
||||||
- name: Stop sigvild-gallery service before restoration
|
- name: Stop sigvild-gallery service before restoration
|
||||||
systemd:
|
systemd:
|
||||||
name: sigvild-gallery
|
name: sigvild-gallery
|
||||||
state: stopped
|
state: stopped
|
||||||
register: service_stopped_for_restore
|
register: service_stopped_for_restore
|
||||||
ignore_errors: true # Service might not exist on fresh deployment
|
when: sigvild_service_file.stat.exists
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Display service stop status
|
||||||
|
debug:
|
||||||
|
msg: "{{ 'Service stopped for restoration' if sigvild_service_file.stat.exists else 'Service does not exist yet - skipping stop' }}"
|
||||||
|
|
||||||
- name: Upload backup to remote server
|
- name: Upload backup to remote server
|
||||||
copy:
|
copy:
|
||||||
@@ -116,11 +135,13 @@
|
|||||||
- "Restored data size: {{ restored_size.stdout }}"
|
- "Restored data size: {{ restored_size.stdout }}"
|
||||||
- "Location: {{ sigvild_gallery_data_dir }}"
|
- "Location: {{ sigvild_gallery_data_dir }}"
|
||||||
|
|
||||||
when: backup_files.files | length > 0
|
when:
|
||||||
|
- backup_files.files | length > 0
|
||||||
|
- not existing_data.stat.exists
|
||||||
|
|
||||||
- name: No backup available message
|
- name: No backup available message
|
||||||
debug:
|
debug:
|
||||||
msg:
|
msg:
|
||||||
- "ℹ️ No backup files found - starting with fresh installation"
|
- "ℹ️ No backup files found - starting with fresh installation"
|
||||||
- "Data directory will be created empty: {{ sigvild_gallery_data_dir }}"
|
- "Data directory will be created empty: {{ sigvild_gallery_data_dir }}"
|
||||||
when: backup_files.files | length == 0
|
when: backup_files.files | length == 0
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ WorkingDirectory={{ sigvild_gallery_home }}
|
|||||||
ExecStart={{ sigvild_gallery_binary }} serve --http={{ sigvild_gallery_host }}:{{ sigvild_gallery_port }}
|
ExecStart={{ sigvild_gallery_binary }} serve --http={{ sigvild_gallery_host }}:{{ sigvild_gallery_port }}
|
||||||
|
|
||||||
# Environment variables
|
# Environment variables
|
||||||
Environment="SIGVILD_ENVIRONMENT"="production" # Lets caddy handle CORS
|
Environment="SIGVILD_ENVIRONMENT"="production"
|
||||||
Environment="HOST_USERNAME={{ sigvild_gallery_host_username }}"
|
Environment="HOST_USERNAME={{ sigvild_gallery_host_username }}"
|
||||||
Environment="HOST_PASSWORD={{ sigvild_gallery_host_password }}"
|
Environment="HOST_PASSWORD={{ sigvild_gallery_host_password }}"
|
||||||
Environment="HOST_DISPLAY_NAME=Wedding Host"
|
Environment="HOST_DISPLAY_NAME=Wedding Host"
|
||||||
|
|||||||
Reference in New Issue
Block a user