forked from welaika/wp_haml_sass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
30 lines (26 loc) · 1.33 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
ssh_user = "[email protected]"
remote_root = "/var/www/your_wp_site/wp-content/themes/your_theme/"
vhost = "http://your_wp_site.com"
local_db_user = "your_user"
local_db_password = "your_password"
local_db_name = "your_db_name"
remote_db_user = "your_user"
remote_db_password = "your_password"
remote_db_name = "your_db_name"
# Usage:
# $ rake push
desc "push"
task :push do
# export all the local Wordpress data into dump.sql
system "mysqldump --user #{local_db_user} -p#{local_db_password} #{local_db_name} wp_posts wp_postmeta wp_term_relationships wp_term_taxonomy wp_terms wp_options > dump.sql"
# replace the domain name to the remote one
system "echo 'UPDATE wp_options SET option_value=\"#{vhost}\" WHERE option_name=\"siteurl\" OR option_name=\"home\";' >> dump.sql"
# copy remotely all the theme directory
system "rsync -avz --exclude-from=.rsync_exclude --delete . #{ssh_user}:#{remote_root}"
# copy remotely all the uploads directory
system "rsync -avz --exclude-from=.rsync_exclude --delete ../../uploads/ #{ssh_user}:#{remote_root}../../uploads/"
# import remotely dump.sql
system "ssh #{ssh_user} 'cd #{remote_root} && mysql --user #{remote_db_user} -p#{remote_db_password} -D #{remote_db_name} < dump.sql && rm dump.sql'"
# that's it remove dump.sql
system "rm dump.sql"
end