命令行数据库仅备份

discourse backup creates a backup with uploads, regardless of the site setting that controls that. Is there a way to do a database only backup from the command line? It would be handy to be able do this for a number of reasons.

3 个赞
6 个赞

Thanks! I read enough here that I think I know and remember everything that’s been posted and sometimes forget to search. :man_shrugging:

I marked your post as the solution, but here’s the one-liner:

/var/discourse/launcher run app "echo 'BackupRestore::Backuper.new(Discourse.system_user.id, with_uploads: false).run' | rails c"
4 个赞

谨此记录,供日后参考:

# 进入 docker 容器,或 ./launcher enter <dockername>
docker exec -it <dockername> bash
# 运行 rails console 时,别忘了为多站点指定数据库
RAILS_DB=db_name rails c
# 查看命令:
BackupRestore::Backuper.new(Discourse.system_user.id, with_uploads: false)
# 然后运行备份命令
BackupRestore::Backuper.new(Discourse.system_user.id, with_uploads: false).run

此主题在上次回复后 30 天自动关闭。不再允许回复。