当前位置:   article > 正文

迁移 docker Jellyfin 到全新机器_jellyfin 迁移

jellyfin 迁移

CSDN 对 HTML 标签支持的不好,点击跳转我的 Github blog 获取更好的体验

0. 前言

各设备 IP:
NAS: 192.168.31.20
旧设备: 192.168.31.21
新设备: 192.168.31.31

1. 旧机器导出 jellyfin 数据

旧机器 docker 容器的详情 这是我的 QNAP 设备
[/share/Installer/temp_20210811] # docker inspect e153ae723f1a
[
    {
        "Id": "e153ae723f1ab69a3c62cc7c926d1ffda268056d38833949e0db83ad7782b2ca",
        "Created": "2020-03-16T16:16:17.153304574Z",
        "Path": "./jellyfin/jellyfin",
        "Args": [
            "--datadir",
            "/config",
            "--cachedir",
            "/cache",
            "--ffmpeg",
            "/usr/local/bin/ffmpeg"
        ],
        "State": {
            "Status": "exited",
            "Running": false,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 0,
            "ExitCode": 143,
            "Error": "",
            "StartedAt": "2021-03-10T14:41:26.253973907Z",
            "FinishedAt": "2021-08-10T17:53:21.548132521Z"
        },
        "Image": "sha256:f4a95483e8262f36c3581d01b4f797f6a625e39f80181d56e0e0329f93d3f12b",
        "ResolvConfPath": "/share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/containers/e153ae723f1ab69a3c62cc7c926d1ffda268056d38833949e0db83ad7782b2ca/resolv.conf",
        "HostnamePath": "/share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/containers/e153ae723f1ab69a3c62cc7c926d1ffda268056d38833949e0db83ad7782b2ca/hostname",
        "HostsPath": "/share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/containers/e153ae723f1ab69a3c62cc7c926d1ffda268056d38833949e0db83ad7782b2ca/hosts",
        "LogPath": "/share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/containers/e153ae723f1ab69a3c62cc7c926d1ffda268056d38833949e0db83ad7782b2ca/e153ae723f1ab69a3c62cc7c926d1ffda268056d38833949e0db83ad7782b2ca-json.log",
        "Name": "/jellyfin-1-temporary-1590291633",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/share/jellyfin/cache:/cache",
                "/share/media:/media",
                "/share/jellyfin/config:/config"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "host",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "shareable",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [
                {
                    "PathOnHost": "/dev/dri/renderD128",
                    "PathInContainer": "/dev/dri/renderD128",
                    "CgroupPermissions": "rwm"
                }
            ],
            "DeviceCgroupRules": null,
            "DiskQuota": 0,
            "KernelMemory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": 0,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/overlay2/42fae3b91ee5d46d270ba2ac8681c04e9fd7b22d75a8c71bdf25c6af45580cf0-init/diff:/share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/overlay2/cf0759cb81923b0f57e7a909cd174185255e9b617340e97ce454a8eb7fb7a747/diff:/share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/overlay2/f0f31c3cec79753a8471292d9b323bca4f8d53bc1cff712a742b9d36d0ce80b7/diff:/share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/overlay2/b7499b5bf659d5b211f4b10d72599b629f3c3541fb1cbd220a0e1ad602403723/diff:/share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/overlay2/1746d846c3e1ed4cdc6f125ebbd86e830a51935130ab2692c764e692c289d223/diff:/share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/overlay2/ca5b3391c32348ac738d8158be04146e3591cab75b7bb688cf35f07a0067124c/diff",
                "MergedDir": "/share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/overlay2/42fae3b91ee5d46d270ba2ac8681c04e9fd7b22d75a8c71bdf25c6af45580cf0/merged",
                "UpperDir": "/share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/overlay2/42fae3b91ee5d46d270ba2ac8681c04e9fd7b22d75a8c71bdf25c6af45580cf0/diff",
                "WorkDir": "/share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/overlay2/42fae3b91ee5d46d270ba2ac8681c04e9fd7b22d75a8c71bdf25c6af45580cf0/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/share/jellyfin/cache",
                "Destination": "/cache",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/share/jellyfin/config",
                "Destination": "/config",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/share/media",
                "Destination": "/media",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "nHan-453Bmini",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": true,
            "AttachStderr": true,
            "ExposedPorts": {
                "8096/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NVIDIA_DRIVER_CAPABILITIES=compute,video,utility",
                "DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1"
            ],
            "Cmd": null,
            "Image": "jellyfin/jellyfin:latest",
            "Volumes": {
                "/cache": {},
                "/config": {},
                "/media": {}
            },
            "WorkingDir": "",
            "Entrypoint": [
                "./jellyfin/jellyfin",
                "--datadir",
                "/config",
                "--cachedir",
                "/cache",
                "--ffmpeg",
                "/usr/local/bin/ffmpeg"
            ],
            "OnBuild": null,
            "Labels": {}
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "6a5645d3bf40514fee310142bc4ae2a85765f787104cbd2695b2236208ee0782",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/default",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "host": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "0cade7f3f08c241ceec07a5c1dce07079145a89c2f6500d674f4d367810dab68",
                    "EndpointID": "",
                    "Gateway": "",
                    "IPAddress": "",
                    "IPPrefixLen": 0,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "",
                    "DriverOpts": null
                }
            }
        }
    }
]

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234

其中 cache, config, media 这几个目录是需要被 copy 到新机器的,其中 media 我是通过 smb 挂载的,所以这里我就无需复制了。

2. 新机器挂载远程 media 目录

永久挂载,直接修改 /etc/fstab 文件:

sudo cat <<EOF >>/etc/fstab
//192.168.31.20/media /mnt/media cifs defaults,username=YOUR_SMB_USERNAME,password=YOUR_SMB_PASSWORD
EOF
sudo mount -a
  • 1
  • 2
  • 3
  • 4

如果你要的是临时挂载:

sudo mount -o username=YOUR_SMB_USERNAME,password=YOUR_SMB_PASSWORD //192.168.31.20/media /mnt/media
  • 1

3. 新机器安装 docker Jellyfin

注意:这里已经安装了 docker, docker-compose

mkdir jellyfin && cd jellyfin
# 将最开始备份的 config, cache 复制到 jellyfin 目录,这里我用的是 rz 命令上传备份 zip 的
rz
unzip jellyfin.zip
  • 1
  • 2
  • 3
  • 4

此时目录应该有 config, cache 两个目录。然后继续上面的命令启动 docker:

touch docker-compose.yaml
cat <<EOF >docker-compose.yaml
version: '3'
services:
  jellyfin:
    image: jellyfin/jellyfin:latest
    user: 1000:1000
    restart: unless-stopped
    network_mode: host
    volumes:
      - ./config:/config
      - /mnt/media:/media
      - ./cache:/cache
    environment:
      - JELLYFIN_PublishedServerUrl=http://media.home.com
EOF

sudo docker-compose up -d
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

注意,这里有个问题,第一次启动时,旧用户密码未加载,需要重启一次 docker 才能正常登录旧用户,原因未知。

4. 新机器安装 Nginx 并配置

sudo apt install nginx
sudo touch /etc/nginx/sites-available/jellyfin
sudo cat <<EOF >/etc/nginx/sites-available/jellyfin
server {
    listen 80;
    server_name media.home.com;

    location / {
        proxy_pass http://127.0.0.1:8096;
    }
}
EOF
sudo ln -s /etc/nginx/sites-available/jellyfin /etc/nginx/sites-enabled/jellyfin
sudo nginx -s reload
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

5. 修改 dnsmasq,将域名映射到新机器

这里我的路由器是 Padavan,所以直接在路由器界面设置即可,以前的配置为:

address=/home.com/192.168.31.21
  • 1

修改为:

address=/media.home.com/192.168.31.31
address=/home.com/192.168.31.21
  • 1
  • 2

6. 大功告成

image

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/158387
推荐阅读
相关标签
  

闽ICP备14008679号