Adding backup restore to the sync script, omitting dir times with rsync
This commit is contained in:
parent
049256025a
commit
b8059fbbbb
|
|
@ -77,10 +77,10 @@ ENVEOF
|
||||||
# Create sync script for staging dirs
|
# Create sync script for staging dirs
|
||||||
cat > /home/cmc/sync_prod_to_staging.sh <<'EOF'
|
cat > /home/cmc/sync_prod_to_staging.sh <<'EOF'
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
rsync -a --delete /mnt/vault/pdf/ /home/cmc/cmc-sales-staging/app/webroot/pdf/
|
rsync -a --delete --omit-dir-times /mnt/vault/pdf/ /home/cmc/cmc-sales-staging/app/webroot/pdf/
|
||||||
rsync -a --delete /mnt/vault/attachments_files/ /home/cmc/cmc-sales-staging/app/webroot/attachments_files/
|
rsync -a --delete --omit-dir-times /mnt/vault/attachments_files/ /home/cmc/cmc-sales-staging/app/webroot/attachments_files/
|
||||||
rsync -a --delete /mnt/vault/emails/ /home/cmc/cmc-sales-staging/vault/emails/
|
rsync -a --delete --omit-dir-times /mnt/vault/emails/ /home/cmc/cmc-sales-staging/vault/emails/
|
||||||
rsync -a --delete /mnt/vault/vaultmsgs/ /home/cmc/cmc-sales-staging/vault/vaultmsgs/
|
rsync -a --delete --omit-dir-times /mnt/vault/vaultmsgs/ /home/cmc/cmc-sales-staging/vault/vaultmsgs/
|
||||||
EOF
|
EOF
|
||||||
chmod +x /home/cmc/sync_prod_to_staging.sh
|
chmod +x /home/cmc/sync_prod_to_staging.sh
|
||||||
|
|
||||||
|
|
@ -92,6 +92,14 @@ EOF
|
||||||
if [[ "$RUN_SYNC" == "true" ]]; then
|
if [[ "$RUN_SYNC" == "true" ]]; then
|
||||||
echo "Running sync_prod_to_staging.sh now..."
|
echo "Running sync_prod_to_staging.sh now..."
|
||||||
/home/cmc/sync_prod_to_staging.sh
|
/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
|
fi
|
||||||
|
|
||||||
echo "Deployment complete."
|
echo "Deployment complete."
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue