Skip to content

Commit 8373d06

Browse files
committed
Merge branch 'release/v1.7.1'
2 parents d7f0aa8 + 7316c2b commit 8373d06

File tree

8 files changed

+58
-19
lines changed

8 files changed

+58
-19
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [1.7.1] - 2021-07-30
10+
### Changed
11+
- Database dump no includes the --no-tablespaces option to stop PROCESS provilege error. (Requires n98-magerun >4.3.0).
12+
- WordPress backup now runs search-replace on remote host export.
13+
- Magento database import now uses n98-magerun to import database.
14+
- WordPress import now uses wp-cli to import database.
15+
- Tidy up of unneeded variables.
16+
17+
918
## [1.7.0] - 2021-04-27
1019
### Added
1120
- New flag to add prefix to sales orders, invoices, credit memos and shipments.

MENU.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Use the below to generate the menu.sh file from the site [https://argbash.io/gen
44

55
```
66
#!/bin/bash
7-
# version="1.7.0"
7+
# version="1.7.1"
88
#
99
# This is an optional arguments-only example of Argbash potential
1010
#

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Magento 2 Production DB Sync v1.7.0
1+
# Magento 2 Production DB Sync v1.7.1
22

33
## About
44
A script to copy over a production database to another server, also has the ability to copy across imagery.
@@ -8,6 +8,7 @@ Currently the script is configured to attempt Magento 2 and WordPress database m
88
## Requirements
99
- You need curl installed locally.
1010
- The excellent [n98-magerun2](https://github.com/netz98/n98-magerun2) needs to be installed on both the local machine and the production machine. (Needs to be executable as n98-magerun).
11+
- WP-CLI needs to be installed when working with WordPress as well.
1112
- MySQL (or equivalent) needs to be installed on both the local machine and the server (obviously).
1213
- Magento 2 needs to be installed and configured on both the local and the host machine.
1314
- rsync needs to be installed locally.

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
}
88

99
dbsync_latest_version() {
10-
echo "v1.7.0"
10+
echo "v1.7.1"
1111
}
1212

1313
#

utils/local_import.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ echo
55
echo -e "${txt_blue} Importing into local database(s).${txt_end}"
66
echo
77

8-
mysql -h$DB_HOST -u$DB_USER -p$DB_PASS $DB_DBASE<$local_backup_dir/latest-m2.sql
8+
n98-magerun db:import --drop-tables $local_backup_dir/latest-m2.sql
99

1010
if [ $_arg_wordpress == 'on' ]; then
11-
mysql -h$DB_WP_HOST -u$DB_WP_USER -p$DB_WP_PASS $DB_WP_DBASE<$local_backup_dir/latest-wp.sql
11+
cd wp
12+
sed -i '1s/^/SET SQL_MODE='\''ALLOW_INVALID_DATES'\'';\n\n/' $local_backup_dir/latest-wp.sql
13+
14+
wp db import $local_backup_dir/latest-wp.sql
1215
fi

utils/menu.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
version="1.7.0"
2+
version="1.7.1"
33

44
die()
55
{

utils/remote_backup.sh

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,53 @@ if [ $_arg_full == 'on' ]; then
99
fi
1010
printf "${bg_black}${txt_white}%-80s${txt_end}\n" " "
1111

12+
# Get the URL from n98, if the first option fails it'll try the next
13+
if ! CURRENT_URL=$(n98-magerun config:env:show system.default.web.secure.base_url); then
14+
CURRENT_URL=$(n98-magerun config:show web/secure/base_url)
15+
fi
16+
17+
new_domain=${CURRENT_URL,,}
18+
# remove http://
19+
new_domain=$(printf '%s' "${new_domain}" | sed 's/^http:\/\///g')
20+
# remove https://
21+
new_domain=$(printf '%s' "${new_domain}" | sed 's/^https:\/\///g')
22+
# remove ://
23+
new_domain=$(printf '%s' "${new_domain}" | sed 's/^:\/\///g')
24+
# remove //
25+
new_domain=$(printf '%s' "${new_domain}" | sed 's/^\/\///g')
26+
# remove www.
27+
new_domain=$(printf '%s' "${new_domain}" | sed 's/^www\.//g')
28+
# trim multiple and trailing slashes
29+
new_domain=$(echo ${new_domain} | sed 's:/*$::')
30+
31+
old_domain=${remote_domain,,}
32+
# remove http://
33+
old_domain=$(printf '%s' "${old_domain}" | sed 's/^http:\/\///g')
34+
# remove https://
35+
old_domain=$(printf '%s' "${old_domain}" | sed 's/^https:\/\///g')
36+
# remove ://
37+
old_domain=$(printf '%s' "${old_domain}" | sed 's/^:\/\///g')
38+
# remove //
39+
old_domain=$(printf '%s' "${old_domain}" | sed 's/^\/\///g')
40+
41+
# replace . with \.
42+
old_domain="${old_domain//./\.}"
43+
44+
# trim multiple and trailing slashes
45+
old_domain=$(echo ${old_domain} | sed 's:/*$::')
46+
1247
ssh -p "${remote_port}" "${remote_username}@${remote_host}" <<ENDSSH
1348
mkdir -p $remote_backup_dir
1449
cd $remote_magento_dir
1550
16-
REMOTE_DB_WP_HOST=$(n98-magerun config:env:show db.connection.wordpress.host)
17-
REMOTE_DB_WP_USER=$(n98-magerun config:env:show db.connection.wordpress.username)
18-
REMOTE_DB_WP_PASS=$(n98-magerun config:env:show db.connection.wordpress.password)
19-
REMOTE_DB_WP_DBASE=$(n98-magerun config:env:show db.connection.wordpress.dbname)
20-
2151
if [ $_arg_full == 'on' ]; then
22-
n98-magerun --quiet --no-interaction db:dump --compression="gzip" --strip="@log @sessions" --force $remote_backup_dir/latest-m2.sql.gz
52+
n98-magerun --quiet --no-interaction db:dump --no-tablespaces --compression="gzip" --strip="@log @sessions" --force $remote_backup_dir/latest-m2.sql.gz
2353
else
24-
n98-magerun --quiet --no-interaction db:dump --compression="gzip" --strip="@log @sessions @trade @sales $ignore_tables" --force $remote_backup_dir/latest-m2.sql.gz
54+
n98-magerun --quiet --no-interaction db:dump --no-tablespaces --compression="gzip" --strip="@log @sessions @trade @sales $ignore_tables" --force $remote_backup_dir/latest-m2.sql.gz
2555
fi
2656
2757
if [ $_arg_wordpress == 'on' ]; then
28-
n98-magerun --quiet --no-interaction db:dump --compression="gzip" --connection="wordpress" --force $remote_backup_dir/latest-wp.sql.gz
58+
cd wp
59+
wp search-replace 'http[s]?:\/\/(?:www\.)?$old_domain' 'https://$new_domain' --regex --export | gzip > $remote_backup_dir/latest-wp.sql.gz
2960
fi
3061
ENDSSH

utils/url_update.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,3 @@ echo -e ""
4141

4242
sed -i "s|www.$old_domain|$new_domain|g" "${local_backup_dir}/latest-m2.sql"
4343
sed -i "s|$old_domain|$new_domain|g" "${local_backup_dir}/latest-m2.sql"
44-
45-
if [ $_arg_wordpress == 'on' ]; then
46-
sed -i "s|www.$old_domain|$new_domain|g" "${local_backup_dir}/latest-wp.sql"
47-
sed -i "s|$old_domain|$new_domain|g" "${local_backup_dir}/latest-wp.sql"
48-
fi

0 commit comments

Comments
 (0)