فهرست منبع

测试服同步生产数据,同步项目文件脚本

haozi 5 سال پیش
والد
کامیت
48911e5ebc
3فایلهای تغییر یافته به همراه50 افزوده شده و 33 حذف شده
  1. 42 13
      bashupMysql.sh
  2. 7 19
      public/.htaccess
  3. 1 1
      syncProject.sh

+ 42 - 13
bashupMysql.sh

@@ -4,9 +4,11 @@
 folder=/etc/bashupMysql
 folder=/etc/bashupMysql
 cd $folder
 cd $folder
 #当前日期
 #当前日期
-time_now=$(date  "+%Y-%m-%d %H:%M:%S")
-#当前时间的前30天
-time_30day_ago=$(date -d"30 day ago" "+%Y-%m-%d %H:%M:%S")
+time_now=$(date  "+%Y-%m-%d")
+#当前时间的前30天 %H:%M:%S
+time_30day_ago=$(date -d"30 day ago" "+%Y-%m-%d 00:00:00")
+#当前日期的前三天
+time_3day_ago=$(date -d"3 day ago" "+%Y-%m-%d")
 #数据库服务器ip,填写服务器的公网地址即可
 #数据库服务器ip,填写服务器的公网地址即可
 host="was.baoshi56.com"
 host="was.baoshi56.com"
 test_host="101.133.135.193"
 test_host="101.133.135.193"
@@ -19,13 +21,40 @@ test_password="123456"
 #要备份的数据库名
 #要备份的数据库名
 db="bswas"
 db="bswas"
 test_db="bswas_test"
 test_db="bswas_test"
-#执行备份语句 -A 是备份所有 --single-transaction 是在导出数据时不锁表
-#mysqldump -h$host -u$user -p$password -A > ./all.sql
-mysqldump -h$host -u$user -p$password --single-transaction $db --ignore-table=$db.orders --ignore-table=$db.stores --ignore-table=$db.store_items --ignore-table=$db.commodities --ignore-table=$db.commodity_barcodes --ignore-table=$db.logs --ignore-table=$db.order_commodities --ignore-table=$db.order_bins --ignore-table=$db.w_m_s_waybill_orders --ignore-table=$db.rejected_bills --ignore-table=$db.rejected_bill_items --ignore-table=$db.w_m_s_reflect_packages --ignore-table=$db.w_m_s_reflect_receive_skus --ignore-table=$db.w_m_s_reflect_receives --ignore-table=$db.order_counting_records --ignore-table=$db.order_package_commodities --ignore-table=$db.order_packages --ignore-table=$db.packages> ./$time_now.all.sql
-#orders order_counting_records order_bins order_packages order_package_commodities
-#stores rejected_bills rejected_bill_items w_m_s_reflect_receive_skus
-#store_items w_m_s_reflect_packages w_m_s_reflect_receives w_m_s_waybill_orders
-#commodities
-#commodity_barcodes
-#logs
-mysql -h$test_host -u$test_user -p$test_password -P 13306 $test_db< ./$time_now.all.sql
+#执行备份语句 --single-transaction 是在导出数据时不锁表
+mysqldump -h$host -u$user -p$password --single-transaction $db --ignore-table=$db.orders --ignore-table=$db.stores --ignore-table=$db.store_items --ignore-table=$db.commodities --ignore-table=$db.commodity_barcodes --ignore-table=$db.logs --ignore-table=$db.order_commodities --ignore-table=$db.order_bins --ignore-table=$db.w_m_s_waybill_orders --ignore-table=$db.rejected_bills --ignore-table=$db.rejected_bill_items --ignore-table=$db.w_m_s_reflect_packages --ignore-table=$db.w_m_s_reflect_receive_skus --ignore-table=$db.w_m_s_reflect_receives --ignore-table=$db.order_counting_records --ignore-table=$db.order_package_commodities --ignore-table=$db.order_packages --ignore-table=$db.packages> $time_nowall.sql
+mysql  -u$test_user -p$test_password  $test_db< $time_nowall.sql
+mysqldump -h$host -u$user -p$password --single-transaction -q -e $db orders --where="created_at>='$time_30day_ago'" > $time_noworders.sql
+mysql  -u$test_user -p$test_password  $test_db< $time_noworders.sql
+mysqldump -h$host -u$user -p$password --single-transaction -q -e $db stores --where="created_at>='$time_30day_ago'" > $time_nowstores.sql
+mysql  -u$test_user -p$test_password  $test_db< $time_nowstores.sql
+mysqldump -h$host -u$user -p$password --single-transaction -q -e $db store_items --where="created_at>='$time_30day_ago'" > $time_nowstore_items.sql
+mysql  -u$test_user -p$test_password  $test_db< $time_nowstore_items.sql
+mysqldump -h$host -u$user -p$password --single-transaction -q -e $db commodities --where="created_at>='$time_30day_ago'" > $time_nowcommodities.sql
+mysql  -u$test_user -p$test_password  $test_db< $time_nowcommodities.sql
+mysqldump -h$host -u$user -p$password --single-transaction -q -e $db commodity_barcodes --where="created_at>='$time_30day_ago'" > $time_nowcommodity_barcodes.sql
+mysql  -u$test_user -p$test_password  $test_db< $time_nowcommodity_barcodes.sql
+mysqldump -h$host -u$user -p$password --single-transaction -q -e $db order_counting_records --where="created_at>='$time_30day_ago'" > $time_noworder_counting_records.sql
+mysql  -u$test_user -p$test_password  $test_db< $time_noworder_counting_records.sql
+mysqldump -h$host -u$user -p$password --single-transaction -q -e $db order_bins --where="created_at>='$time_30day_ago'" > $time_noworder_bins.sql
+mysql  -u$test_user -p$test_password  $test_db< $time_noworder_bins.sql
+mysqldump -h$host -u$user -p$password --single-transaction -q -e $db order_packages --where="created_at>='$time_30day_ago'" > $time_noworder_packages.sql
+mysql  -u$test_user -p$test_password  $test_db< $time_noworder_packages.sql
+mysqldump -h$host -u$user -p$password --single-transaction -q -e $db order_package_commodities --where="created_at>='$time_30day_ago'" > $time_noworder_package_commodities.sql
+mysql  -u$test_user -p$test_password  $test_db< $time_noworder_package_commodities.sql
+mysqldump -h$host -u$user -p$password --single-transaction -q -e $db rejected_bills --where="created_at>='$time_30day_ago'" > $time_nowrejected_bills.sql
+mysql  -u$test_user -p$test_password  $test_db< $time_nowrejected_bills.sql
+mysqldump -h$host -u$user -p$password --single-transaction -q -e $db rejected_bill_items --where="created_at>='$time_30day_ago'" > $time_nowrejected_bill_items.sql
+mysql  -u$test_user -p$test_password  $test_db< $time_nowrejected_bill_items.sql
+mysqldump -h$host -u$user -p$password --single-transaction -q -e $db w_m_s_reflect_receive_skus --where="created_at>='$time_30day_ago'" > $time_noww_m_s_reflect_receive_skus.sql
+mysql  -u$test_user -p$test_password  $test_db< $time_noww_m_s_reflect_receive_skus.sql
+mysqldump -h$host -u$user -p$password --single-transaction -q -e $db w_m_s_reflect_packages --where="created_at>='$time_30day_ago'" > $time_noww_m_s_reflect_packages.sql
+mysql  -u$test_user -p$test_password  $test_db< $time_noww_m_s_reflect_packages.sql
+mysqldump -h$host -u$user -p$password --single-transaction -q -e $db w_m_s_reflect_receives --where="created_at>='$time_30day_ago'" > $time_noww_m_s_reflect_receives.sql
+mysql  -u$test_user -p$test_password  $test_db< $time_noww_m_s_reflect_receives.sql
+mysqldump -h$host -u$user -p$password --single-transaction -q -e $db w_m_s_waybill_orders --where="created_at>='$time_30day_ago'" > $time_noww_m_s_waybill_orders.sql
+mysql  -u$test_user -p$test_password  $test_db< $time_noww_m_s_waybill_orders.sql
+mysqldump -h$host -u$user -p$password --single-transaction -q -e $db order_commodities --where="created_at>='$time_30day_ago'" > $time_noworder_commodities.sql
+mysql  -u$test_user -p$test_password  $test_db< $time_noworder_commodities.sql
+
+sudo rm -rf $time_3day_ago*

+ 7 - 19
public/.htaccess

@@ -1,21 +1,9 @@
-<IfModule mod_rewrite.c>
-    <IfModule mod_negotiation.c>
-        Options -MultiViews -Indexes
-    </IfModule>
+Options +FollowSymLinks -Indexes
+RewriteEngine On
 
 
-    RewriteEngine On
+RewriteCond %{HTTP:Authorization} .
+RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
 
 
-    # Handle Authorization Header
-    RewriteCond %{HTTP:Authorization} .
-    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
-
-    # Redirect Trailing Slashes If Not A Folder...
-    RewriteCond %{REQUEST_FILENAME} !-d
-    RewriteCond %{REQUEST_URI} (.+)/$
-    RewriteRule ^ %1 [L,R=301]
-
-    # Handle Front Controller...
-    RewriteCond %{REQUEST_FILENAME} !-d
-    RewriteCond %{REQUEST_FILENAME} !-f
-    RewriteRule ^ index.php [L]
-</IfModule>
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteRule ^ index.php [L]

+ 1 - 1
syncProject.sh

@@ -1,7 +1,7 @@
 #!/bin/bash
 #!/bin/bash
 
 
 cd $src
 cd $src
-Ip="testwas.baoshi56.com"
+Ip="was.baoshi56.com"
 username="haozi"
 username="haozi"
 password="haozi"
 password="haozi"
 files=("app" "config" "database" "public" "resources" "routes" "webpack.mix.js" "composer.json" "tests")
 files=("app" "config" "database" "public" "resources" "routes" "webpack.mix.js" "composer.json" "tests")