Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. # push a local WP database to an existing staging site
  2. # uses current directory as theme path and ssh alias
  3. pushstage() {
  4. START=$(date +%s)
  5. # make a backup of the current local database
  6. # get current directory name, used for database and URL
  7. current=${PWD##*/}
  8. cd ~/Sites/$current || return
  9.  
  10. # rsync the local database to staging site
  11. wp db export $current.sql
  12. rsync $current.sql $current-s:~/
  13.  
  14. # make a backup of the staging database
  15. wp @stage db export backup.sql
  16. # reset the staging database
  17. wp @stage db reset --yes
  18.  
  19. # import our rsynced local database and update URLs
  20. wp @stage db import $current.sql
  21. wp @stage search-replace "$current.localhost" "$current.dmctest.com.au" --all-tables
  22.  
  23. # deactivate plugins that aren't needed
  24. wp @stage plugin deactivate debug-bar query-monitor acf-theme-code-pro wordpress-seo
  25. # Discourage search engines from indexing this site
  26. wp @stage option update blog_public 0
  27.  
  28. cd ~/Sites/$current/wp-content/themes/$current
  29. END=$(date +%s)
  30. DIFF=$(( $END - $START ))
  31. echo -e "\n$current.localhost database now in use on $push_staging_url site.\nIt took $DIFF seconds, enjoy!\n"
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement