prod #123
|
|
@ -73,19 +73,35 @@ ENVEOF
|
|||
# Check containers
|
||||
docker compose -f docker-compose.stg.yml ps
|
||||
|
||||
echo "Creating restore script for database from backups..."
|
||||
# Create restore script for database from backups
|
||||
cat > /home/cmc/restore_db_from_backup.sh <<'EOF'
|
||||
#!/bin/bash
|
||||
LATEST_BACKUP=$(ls -t /backups/backup_*.sql.gz | head -n1)
|
||||
echo "Restoring database from latest backup: $LATEST_BACKUP"
|
||||
if [ -f "$LATEST_BACKUP" ]; then
|
||||
gunzip < "$LATEST_BACKUP" | mariadb -h 127.0.0.1 -u cmc -p"xVRQI&cA?7AU=hqJ!%au" cmc
|
||||
echo "Database restore complete."
|
||||
else
|
||||
echo "No backup file found in /backups. Skipping database restore."
|
||||
fi
|
||||
EOF
|
||||
chmod +x /home/cmc/restore_db_from_backup.sh
|
||||
|
||||
echo "Creating sync script for staging directories..."
|
||||
# Create sync script for staging dirs
|
||||
cat > /home/cmc/sync_prod_to_staging.sh <<'EOF'
|
||||
#!/bin/bash
|
||||
/home/cmc/restore_db_from_backup.sh
|
||||
|
||||
echo "Syncing PDF files..."
|
||||
rsync -a --delete --omit-dir-times --no-perms --progress /mnt/vault/pdf/ /home/cmc/cmc-sales-staging/app/webroot/pdf/
|
||||
rsync -av --delete --omit-dir-times --no-perms --progress /mnt/vault/pdf/ /home/cmc/cmc-sales-staging/app/webroot/pdf/
|
||||
echo "Syncing attachments files..."
|
||||
rsync -a --delete --omit-dir-times --no-perms --progress /mnt/vault/attachments_files/ /home/cmc/cmc-sales-staging/app/webroot/attachments_files/
|
||||
rsync -av --delete --omit-dir-times --no-perms --progress /mnt/vault/attachments_files/ /home/cmc/cmc-sales-staging/app/webroot/attachments_files/
|
||||
echo "Syncing emails..."
|
||||
rsync -a --delete --omit-dir-times --no-perms --progress /mnt/vault/emails/ /home/cmc/cmc-sales-staging/vault/emails/
|
||||
rsync -av --delete --omit-dir-times --no-perms --progress /mnt/vault/emails/ /home/cmc/cmc-sales-staging/vault/emails/
|
||||
echo "Syncing vaultmsgs..."
|
||||
rsync -a --delete --omit-dir-times --no-perms --progress /mnt/vault/vaultmsgs/ /home/cmc/cmc-sales-staging/vault/vaultmsgs/
|
||||
rsync -av --delete --omit-dir-times --no-perms --progress /mnt/vault/vaultmsgs/ /home/cmc/cmc-sales-staging/vault/vaultmsgs/
|
||||
echo "Sync complete."
|
||||
EOF
|
||||
chmod +x /home/cmc/sync_prod_to_staging.sh
|
||||
|
|
@ -98,14 +114,6 @@ EOF
|
|||
if [[ "$RUN_SYNC" == "true" ]]; then
|
||||
echo "Running sync_prod_to_staging.sh now..."
|
||||
/home/cmc/sync_prod_to_staging.sh
|
||||
echo "Restoring database from latest backup in /backups..."
|
||||
LATEST_BACKUP=$(ls -t ./backups/backup_*.sql.gz | head -n1)
|
||||
if [ -f "$LATEST_BACKUP" ]; then
|
||||
gunzip < "$LATEST_BACKUP" | mariadb -h 127.0.0.1 -u cmc -p"xVRQI&cA?7AU=hqJ!%au" cmc
|
||||
echo "Database restore complete."
|
||||
else
|
||||
echo "No backup file found in /backups. Skipping database restore."
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Deployment complete."
|
||||
|
|
|
|||
Loading…
Reference in a new issue