# Sshfs 和备份

**URL:** https://meta.discourse.org/t/sshfs-and-backup/256225
**Category:** Self-hosting
**Tags:** backups
**Created:** [2023年二月25日 05:51 UTC](https://meta.discourse.org/t/sshfs-and-backup/256225 "2023-02-25T05:51:40Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![puchal](https://avatars.discourse-cdn.com/v4/letter/p/87869e/32.png) [@puchal](https://meta.discourse.org/u/puchal)
#### Post date: [2023年二月25日 05:51 UTC](https://meta.discourse.org/t/sshfs-and-backup/256225/1 "2023-02-25T05:51:40Z")

</div>

您好，  
我为一个小社区托管 Discourse。我们有一个非常小的、旧的 VPS。磁盘空间已无法容纳备份，所以我做了一个快速的技巧，将远程文件系统（使用 sshfs）挂载为 `/var/discourse/shared/standalone/backups/default`。一切似乎都正常，我可以在 `/var/www/discourse/public/backups/default/` 中创建/删除文件或目录，但当我尝试运行备份时，它会失败。有什么办法可以解决这个问题吗？权限设置为 777。

另外，也许在软件的下一个版本中，禁用备份压缩的选项终于会出现？这样我们就可以节省几年的存储空间 🙂

谢谢！

```plaintext
[2023-02-25 04:41:33] pg_dump: executing SEQUENCE SET category_featured_topics_id_seq
[2023-02-25 04:41:33] pg_dump: executing SEQUENCE SET category_groups_id_seq
[2023-02-25 04:41:33] pg_dump: executing SEQUENCE SET category_required_tag_groups_id_seq
[2023-02-25 04:41:33] pg_dump: executing SEQUENCE SET category_tag_groups_id_seq
[2023-02-25 04:41:33] pg_dump: executing SEQUENCE SET category_tag_stats_id_seq
[2023-02-25 04:41:33] Finalizing backup...
[2023-02-25 04:41:33] Creating archive: p-e-2023-02-25-043914-v20230201192925.tar.gz
[2023-02-25 04:41:33] Making sure archive does not already exist...
[2023-02-25 04:41:34] EXCEPTION: /var/www/discourse/lib/discourse.rb:137:in `exec': rm: cannot remove '/var/www/discourse/public/backups/default/p-e-2023-02-25-043914-v20230201192925.tar': Permission denied

[2023-02-25 04:41:34] /var/www/discourse/lib/discourse.rb:171:in `execute_command'
/var/www/discourse/lib/discourse.rb:137:in `exec'
/var/www/discourse/lib/discourse.rb:33:in `execute_command'
/var/www/discourse/lib/backup_restore/backuper.rb:216:in `create_archive'
/var/www/discourse/lib/backup_restore/backuper.rb:40:in `run'
/var/www/discourse/script/spawn_backup_restore.rb:9:in `backup'
/var/www/discourse/script/spawn_backup_restore.rb:31:in `block in <main>'
/var/www/discourse/script/spawn_backup_restore.rb:4:in `fork'
/var/www/discourse/script/spawn_backup_restore.rb:4:in `<main>'
[2023-02-25 04:41:34] Deleting old backups...
[2023-02-25 04:41:34] Cleaning stuff up...
[2023-02-25 04:41:34] Removing '.tar' leftovers...
[2023-02-25 04:41:34] Marking backup as finished...
[2023-02-25 04:41:34] Refreshing disk stats...
[2023-02-25 04:41:34] Notifying 'siteadmin' of the end of the backup...
[2023-02-25 04:41:42] Finished!

```

---

<div class="post-metadata">

### Author: ![puchal](https://avatars.discourse-cdn.com/v4/letter/p/87869e/32.png) [@puchal](https://meta.discourse.org/u/puchal)
#### Post date: [2023年三月1日 13:41 UTC](https://meta.discourse.org/t/sshfs-and-backup/256225/2 "2023-03-01T13:41:35Z")

</div>

没人？有什么办法可以修复它（除了某种我不知道的，通过 ssh 隧道进行 nfs）？ ☹

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [2023年三月1日 13:55 UTC](https://meta.discourse.org/t/sshfs-and-backup/256225/3 "2023-03-01T13:55:27Z")

</div>

磁盘很便宜，Discourse 迁移是最简单的迁移之一。可能值得考虑迁移 VPS。如果你目前无法进行备份，那么像 PostgreSQL 升级这样的事情将是完全无法进行的。

对于大多数人来说，投入时间在这上面是不值得的，因为时间比多出来的几 GB 更宝贵。

---

<div class="post-metadata">

### Author: ![leonardo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leonardo/32/228634_2.png) [@leonardo](https://meta.discourse.org/u/leonardo)
#### Post date: [2023年三月1日 14:22 UTC](https://meta.discourse.org/t/sshfs-and-backup/256225/4 "2023-03-01T14:22:24Z")

</div>

您好！

这很可能是因为 Discourse 的备份过程是以有效的用户 ID 0 运行的，因此您可能需要将 [此选项](https://wiki.gentoo.org/wiki/SSHFS#Permissions_based_options) 传递给 `sshfs`：

```bash
sshfs -o allow_root SERVER:PATH MOUNT_POINT

```

或者，如果您使用的是非特权容器，则改用 `allow_other`。

---

<div class="post-metadata">

### Author: ![puchal](https://avatars.discourse-cdn.com/v4/letter/p/87869e/32.png) [@puchal](https://meta.discourse.org/u/puchal)
#### Post date: [2023年三月1日 16:51 UTC](https://meta.discourse.org/t/sshfs-and-backup/256225/5 "2023-03-01T16:51:10Z")

</div>

你愿意捐赠一些便宜的磁盘吗？ 😉

---

<div class="post-metadata">

### Author: ![puchal](https://avatars.discourse-cdn.com/v4/letter/p/87869e/32.png) [@puchal](https://meta.discourse.org/u/puchal)
#### Post date: [2023年三月1日 16:52 UTC](https://meta.discourse.org/t/sshfs-and-backup/256225/6 "2023-03-01T16:52:33Z")

</div>

谢谢，我会试试的。这很有道理。 👍
