def restore_db_docker(self, zipfile):
command = ''' /usr/bin/7z x -so {} dump.sql | ''' \
''' docker run -i --rm --link {}:{} postgres:{} ''' \
''' /bin/bash -c 'echo "{}:5432:*:{}:{}" ''' \
''' > ~/.pgpass; chmod 600 ~/.pgpass; ''' \
''' /usr/lib/postgresql/{}/bin/psql ''' \
''' -q -h {} -U {} {} > /dev/null' ''' \
.format(zipfile, self.db_host, self.db_host, self.pgversion,
self.db_host, self.db_user, self.db_password,
self.pgversion, self.db_host, self.db_user,
self.target_db
)
subprocess.check_call(command, shell=True)
评论列表
文章目录