Comments (7)
The workflow I use for that is I have Forge set up to auto-deploy when pushed to the staging
or develop
branch of my Git repo.
So I don't really need a script to do that; if you want to then pull the db
from local
to staging, you could either set up the config on the staging server to pull the db from your local dev, or yeah, you could make a push_db
script analogous to the pull_db
script that would do the opposite.
Pull requests would be awesome if you do decide to make a push_db
script; it should be quite simple to do by modifying the pull_db
script.
from craft-scripts.
@shornuk you should try using a workflow as described here:
https://nystudio107.com/blog/database-asset-syncing-between-environments-in-craft-cms
You absolutely can pull the db & assets to your staging environment; just set up a .env.sh
for that environment as well.
from craft-scripts.
If you do, you might also want to make an analogous push_assets
script as well.
from craft-scripts.
Has anything happened with this? I may be misunderstanding how these scripts should be utilised, but our current setup is production
branch connected to master
db. All changes to the database are made on the master
, then the scripts pulls the db and assets down locally to my local env. Now we have a staging env as well, so ideally I'd like to pull the master
db and assets down to this env, or push them up from my local to it as it's essentially the same. Is this currently possible?
from craft-scripts.
@sjelfull did you ever work up a workflow for pushing_db
& push_assets
?
from craft-scripts.
Naah, I did not. Someday
from craft-scripts.
@chasegiunta @sjelfull Anyone think this would work for pushing the local database to the remote database? I tried to plug into their scripts and variables as much as possible. This has been tested in pieces, but not as a whole. I'm about 99% sure it should work, but 1% of me still thinks it will crash everything : P
One of my main concerns is that running the remote restore_db.sh
script will overwrite local variables with remote variables. I'm still setting up the remote *.env.sh
file, so am not sure if this will create issues. Should be able to test for this issue later this week with "echo" statements.
push_db.sh
#!/bin/bash
# Get the directory of the currently executing script
DIR="$(dirname "${BASH_SOURCE[0]}")"
# Include files
INCLUDE_FILES=(
"common/defaults.sh"
".env.sh"
"common/common_env.sh"
"common/common_db.sh"
)
for INCLUDE_FILE in "${INCLUDE_FILES[@]}"; do
if [[ ! -f "${DIR}/${INCLUDE_FILE}" ]] ; then
echo "File ${DIR}/${INCLUDE_FILE} is missing, aborting."
exit 1
fi
source "${DIR}/${INCLUDE_FILE}"
done
# Backup local database:
./backup_db.sh
# Set the backup db file name, parent directory path, and full path
BACKUP_DB_DIR_PATH="${LOCAL_BACKUPS_PATH}${LOCAL_DB_NAME}/${DB_BACKUP_SUBDIR}/"
BACKUP_DB_NAME="$(basename $(ls -t $BACKUP_DB_DIR_PATH*.sql* | head -1))";
BACKUP_DB_PATH="${BACKUP_DB_DIR_PATH}${BACKUP_DB_NAME}";
# Copy local backup to server:
echo "*** Copying $BACKUP_DB_PATH to $REMOTE_BACKUPS_PATH$BACKUP_DB_NAME";
scp "$BACKUP_DB_PATH" "$REMOTE_SSH_LOGIN:$REMOTE_BACKUPS_PATH$BACKUP_DB_NAME";
# Log into server and restore local backup
ssh -t $REMOTE_SSH_LOGIN << EOF
"${REMOTE_ROOT_PATH}scripts/restore_db.sh" "$REMOTE_BACKUPS_PATH$BACKUP_DB_NAME";
EOF
# Normal exit
exit 0
from craft-scripts.
Related Issues (20)
- sync_backups_to_s3 needs PATH with Laravel Forge scheduler (doc suggestion) HOT 1
- Add support for DigitalOcean Spaces HOT 1
- pull_db.sh fails in certain case HOT 1
- pull_db.sh on local MAMP Pro HOT 1
- exclude tables HOT 1
- ENV Paths Question HOT 1
- pull assets ownership issue HOT 1
- Commerce Orders & Customers HOT 1
- Feature Request: Multiple remotes HOT 3
- How does this work with Craft 3.1 project config? HOT 1
- You have an error in your SQL syntax HOT 1
- X files to consider *** Synced assets ... but nothing seems to have been pulled synced HOT 1
- Skip tables on pull_db HOT 1
- mysql commands on a nitro environment HOT 2
- Unsupported mysqldump args cause scripts to fail with MariaDB HOT 3
- WSL: Host not being used HOT 1
- Permission set with set_perms.sh on ./craft being 644 HOT 1
- No assets being pulled HOT 2
- Issue with pull_db.sh HOT 1
- Support DDEV DB imports HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from craft-scripts.