群晖迁移已安装插件到新存储空间

因为之前用一个固态硬盘做volume1安装各种插件,本来打着省电的出发点,但是群晖只要有了阵列基本硬盘无休,其他不在阵列的硬盘照样子不会休眠的,所以就打算把固态硬盘拔掉用来做SSD缓存算了。

一个一个插件迁移太麻烦了,而且有些系统东西还不支持迁移,直接拔掉固态硬盘会出问题的,还要修复系统太多事了。

上网找了一下,有人写好了脚本,比较适合就拿来用了。

https://gist.github.com/nobodypb/fc3e70b535bcd95b5de7659d6fbda434

如果你不能上GitHub,这里提供本地下载:

move_syno_pkgs

脚本运行记录:

@DS918:/volume2/files$ chmod +x move_syno_pkgs.sh
@DS918:/volume2/files$ sudo sh move_syno_pkgs.sh
Password:
This will move packages from /volume1 to /volume2

New app directory created
Searching for packages on /volume1...
Found AntiVirus
        Move AntiVirus? (y/n)

        Moving AntiVirus...
======== stop AntiVirus ========

======== start AntiVirus ========
        Done. Backup in: /volume1/@appstore/__AntiVirus

Found CloudStationClient
        Move CloudStationClient? (y/n)
Found Docker
        Move Docker? (y/n)

        Moving Docker...
======== stop Docker ========
======== start Docker ========
        Done. Backup in: /volume1/@appstore/__Docker

Found DownloadStation
        Move DownloadStation? (y/n)

        Moving DownloadStation...
======== stop DownloadStation ========
======== start DownloadStation ========
        Done. Backup in: /volume1/@appstore/__DownloadStation

FileStation is not in source directory
Found MariaDB
        Move MariaDB? (y/n)

        Moving MariaDB...
======== stop MariaDB ========

======== start MariaDB ========
        Done. Backup in: /volume1/@appstore/__MariaDB

Found Node.js_v4
        Move Node.js_v4? (y/n)
OAuthService is not in source directory
Found PHP7.0
        Move PHP7.0? (y/n)

        Moving PHP7.0...
======== stop PHP7.0 ========
======== start PHP7.0 ========
        Done. Backup in: /volume1/@appstore/__PHP7.0

Found PHP7.2
        Move PHP7.2? (y/n)

        Moving PHP7.2...
======== stop PHP7.2 ========
======== start PHP7.2 ========
        Done. Backup in: /volume1/@appstore/__PHP7.2

SynoFinder is not in source directory
Found SynologyApplicationService
        Move SynologyApplicationService? (y/n)

        Moving SynologyApplicationService...
======== stop SynologyApplicationService ========
======== start SynologyApplicationService ========
        Done. Backup in: /volume1/@appstore/__SynologyApplicationService

Found SynologyDrive
        Move SynologyDrive? (y/n)

        Moving SynologyDrive...
======== stop SynologyDrive ========
======== start SynologyDrive ========
        Done. Backup in: /volume1/@appstore/__SynologyDrive

Found SynologyMoments
        Move SynologyMoments? (y/n)

        Moving SynologyMoments...
======== stop SynologyMoments ========
======== start SynologyMoments ========
        Done. Backup in: /volume1/@appstore/__SynologyMoments

Found TextEditor
        Move TextEditor? (y/n)

        Moving TextEditor...
======== stop TextEditor ========
======== start TextEditor ========
        Done. Backup in: /volume1/@appstore/__TextEditor

Found VideoStation
        Move VideoStation? (y/n)

        Moving VideoStation...
======== stop VideoStation ========
======== start VideoStation ========
        Done. Backup in: /volume1/@appstore/__VideoStation

Found WebStation
        Move WebStation? (y/n)

        Moving WebStation...
======== stop WebStation ========
======== start WebStation ========
        Done. Backup in: /volume1/@appstore/__WebStation

Found ffmpeg
        Move ffmpeg? (y/n)

        Moving ffmpeg...
======== stop ffmpeg ========
======== start ffmpeg ========
        Done. Backup in: /volume1/@appstore/__ffmpeg

Found imagemagick
        Move imagemagick? (y/n)

        Moving imagemagick...
======== stop imagemagick ========
======== start imagemagick ========
        Done. Backup in: /volume1/@appstore/__imagemagick

Done for all.

If you want to remove /volume1 you should also move the following:

System service symlink /var/services/pgsql to /volume1/@database/pgsql
System service symlink /var/services/tmp to /volume1/@tmp

这样子所有插件就全部从volume 1迁移到了volume 2了,其中Node.js插件会提示要修复,点修复就可以正常使用。
最后输出2个提示说如果要拔掉volume 1的话,还需要处理2个symlink,把pgsql系统数据库迁移到新volume 2那继续处理下就好。
依照脚本的办法:

  • 先复制文件到新地方
  • 删除symlink
  • 建立新symlink
  • 改名旧文件夹

先停止pgsql服务并迁移数据库文件。

@DS918:/volume2$ sudo synoservice --stop pgsql
Password:
some service depend on service [pgsql] is still running, use --hard-stop to stop all releated service
@DS918:/volume2$ sudo synoservice --hard-stop pgsql
warn: The runkey of service [pgsql] and its dependency services have been set to "No"
@DS918:/volume2$ sudo cp -rp /volume1/@database/pgsql /volume2/@database/pgsql
@DS918:/volume2$ sudo rm -f /var/services/pgsql
@DS918:/volume2$ sudo ln -s /volume2/@database/pgsql /var/services/pgsql
@DS918:/volume2$ sudo mv /volume1/@database/pgsql /volume1/@database/_pgsql

对tmp目录采取以上同样步骤,然后删除volume 1,关机拔掉固态硬盘,群晖可以正常开机使用。

1 thought on “群晖迁移已安装插件到新存储空间

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注