feat: backup_database 使用 sudo -u postgres
This commit is contained in:
parent
97026d86c6
commit
92aa602cbe
|
|
@ -14,7 +14,7 @@ def backup_database():
|
|||
import datetime
|
||||
|
||||
name = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
||||
command = 'echo "{}" | sudo -S pg_dump "user={} password={} dbname={}" > {}/bak_{}.sql'.format(
|
||||
command = 'echo "{}" | sudo -S -u postgres pg_dump "user={} password={} dbname={}" > {}/bak_{}.sql'.format(
|
||||
SD_PWD, DATABASES["default"]["USER"], DATABASES["default"]["PASSWORD"], DATABASES["default"]["NAME"], BACKUP_PATH + "/database", name
|
||||
)
|
||||
completed = subprocess.run(command, shell=True, capture_output=True, text=True)
|
||||
|
|
|
|||
Loading…
Reference in New Issue