我们正在尝试通过COPY命令使用psql
postgresql将数据从一个 Amazon RDS 数据库迁移到 Amazon Aurora Serverless 数据库。当我从 EC2 实例运行该脚本时,该脚本运行良好,但我需要手动为rdswizard和postgres每次迭代提供密码。我只想在我的命令中提供密码。如何不每次都手动提供密码和命令?psql
psql
allSites=(3 5 9 11 29 30 31 32 33 34 37 38 39 40 41 45 46 47 48)
for i in "${allSites[@]}"
do
psql \
-X \
-U rdswizard \
-h my_rds_host_url_goes_here \
-d wizard \
-c "\\copy (select site_id,name,phone from client_${i} where date(create_date) > '2019-09-11' LIMIT 100) to stdout" \
| \
psql \
-X \
-U postgres \
-h my_aurora_serverless_host_url_goes_here \
-d wizard \
-c "\\copy client_${i}(site_id,name,phone) from stdin"
done
我的两个数据库主机都在远程服务器上,而不是在本地机器上