I have a bash script on Ubuntu server that is used to do database backups via WP-CLI and use Dropbox Uploader to backup to Dropbox. The script has been working for years on our sites that don't use the Roots Bedrock stack. We recently started use the Bedrock Stack and Capistrano for deploys, and now I want to modify my script to backup databases on these sites. The problem lies in it appears, bash scripts don't understand symlinks for Wordpress path directive. With the Bedrock Stack and server setup, the public directory is a symlink of ~/current/web. Current is the symlink that Capistrano updates to point to the current revision directory. Anyone know how to modify my script to work with symlinks? Here is the script:
#!/bin/bash
# Script to create compressed backup archive of database.
# Set the date format, name, and directory for backups.
NOW=$(date +"%Y%m%d-%H%M")
BACKUP_DIR="/srv/users/serverpilot/apps/backup/public/site"
WP_PATH="/srv/users/serverpilot/apps/site/public"
# MySQL database names
DB_NAME="site_staging"
DB_FILE="site_staging_db_$NOW.sql"
DB_FILEGZ="site_staging_db_$NOW.sql.gz"
# Create the archive and the MySQL dump
wp db export --add-drop-table --path=$WP_PATH $BACKUP_DIR/$DB_FILE
gzip $BACKUP_DIR/$DB_FILE
bash /srv/users/serverpilot/./dropbox_uploader.sh upload $BACKUP_DIR/$DB_FILEGZ /site/