Hi,
When using this script
sync-dev-to-prod-FOR-REAL.sh
Referenced here: Leveraging WP-CLI Aliases in Your WordPress Development Workflow - #2 by benword
When the alias tries to save a backup (just-in-case.sql) I have a permissions problem. Any idea how to fix this?
In my test, I was actually using a staging alias like this:
@staging:
ssh: [email protected] /srv/www/example.com/current
mysqldump: Canāt create/write to file ājust-in-case.sqlā (Errcode: 13 āPermission deniedā)
1 Like
Where does your script currently reside? (In a Trellis/Bedrock setup, it should go in the āsiteā folder).
And where are you running the script? You should be running it from the same directory where the script exists (again the āsiteā folder if youāre using Bedrock).
1 Like
I put my .sh script in ātrellis/binā because thatās where the other .sh script was. Not sure where to put it.
Iām running the script from within the āsiteā folder. The aliases (wp-cli.yml) are in āsiteā.
ben
December 31, 2016, 12:20am
4
Can you try putting it in the āsiteā folder and reporting back?
same permissions error
mysqldump: Canāt create/write to file ājust-in-case.sqlā (Errcode: 13 āPermission deniedā)
This works now.
What I did.
changed the user in the alias to āwebā:
From
@staging:
ssh: [email protected] /srv/www/example.com/current
To
@staging:
ssh: [email protected] /srv/www/domain.com/current
Removed ā-> ā (not sure if this is needed, couldnāt find it in the wp-cli documentation)
From
wp @development db export - > sql-dump-development.sql
To
wp @development db export sql-dump-development.sql
Added a timestamp to the backup (unrelated to fix).
wp @staging db export just-in-case-$(date +%Y-%m-%d_%T).sql
Removed the āsql-dump-development.sqlā file at the end (unrelated to fix).
ssh [email protected] 'rm /srv/www/example.com/current/sql-dump-development.sql'
Complete version
read -r -p "Would you really like to reset THE STAGING DATABASE and send up the latest from dev? [y/N] " response
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
then
wp @development db export sql-dump-development.sql
scp sql-dump-development.sql [email protected] :/srv/www/example.com/current
wp @staging db export just-in-case-$(date +%Y-%m-%d_%T).sql
wp @staging db reset --yes
wp @staging db import sql-dump-development.sql
wp @staging search-replace http://example.dev https://staging.example.com
scp -r web/app/uploads/ [email protected] :/srv/www/example.com/shared
ssh [email protected] 'rm /srv/www/example.com/current/sql-dump-development.sql'
ssh [email protected] 'rm /srv/www/example.com/current/sql-dump-development.sql'
else
exit 0
fi
I would appreciate it if someone more knowledgeable than me can look this over and let me know if anything is totally wacko.
2 Likes
Iāve been looking about to make myself a similar script. Have you figured it out yet?