当前位置: 首页 > 工具软件 > ownCloud > 使用案例 >

部署owncloud连接ladp迁移数据

仲孙焱
2023-12-01

目录

定期 清理日志

查询 用户 的 ldap 语句

开启用户 根据 用户名 登录

迁移数据

backup

迁移数据库

保存 配置文件

迁移数据

ldap config

compose 部署

迁移 用户 数据

图标 更换

server 版本 图标 替换

精简版 版本 图标 替换

修改 上传 限制

修改 文件 限制 后  上传 大文件

同步文件


定期 清理日志


echo '' >  /var/www/html/data/owncloud.log

查询 用户 的 ldap 语句

(|(objectclass=inetOrgPerson)(objectclass=posixAccount)(objectclass=top))


开启用户 根据 用户名 登录

# 默认 是 dc=%uid 修改为 sn 即可

(&(|(objectclass=inetOrgPerson)(objectclass=posixAccount)(objectclass=top))(|(sn=%uid)))

迁移数据


https://doc.owncloud.com/server/10.0/admin_manual/configuration/database/db_conversion.html?highlight=database

https://doc.owncloud.com/server/admin_manual/maintenance/restore.html

backup


https://doc.owncloud.com/server/admin_manual/maintenance/backup.html

迁移数据库

Export SQLite database to dump file using SQLite .dump command.
sqlite3 sample.db .dump > dump.sql
You can then (in theory) import SQLite dump into the MySQL database.
mysql -p -u root -h 127.0.0.1 test < dump.sql

保存 配置文件

cat /free_cicdfs0/data/owncloud_mysql_wuhan/owncloud/config/config.php
<?php
$CONFIG = array (
  'instanceid' => 'ocpe5qldf9j9',
  'passwordsalt' => '+6jcbdQUfk9krdZ78333dzkmv/yYPl',
  'secret' => 'od1u60+zQxcmGkxcMEeu16e2C0Y8tiamZD5Ql4QT7hK2uBKh',
  'trusted_domains' =>
  array (
    0 => '192.168.99.100:50002',
  ),
  'datadirectory' => '/var/www/html/data',
  'overwrite.cli.url' => 'http://192.168.99.100:50002',
  'dbtype' => 'mysql',
  'version' => '10.0.10.4',
  'dbname' => 'owncloud',
  'dbhost' => 'owncloud-mysql',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_admin',
  'dbpassword' => '6EdenAkcQHby0ghLJPKBKnnA1qxrTf',
  'mysql.utf8mb4' => true,
  'logtimezone' => 'UTC',
  'installed' => true,
);

迁移数据

1. 备份 配置文件
   cat /free_cicdfs0/data/owncloud_mysql_wuhan/owncloud/config/config.php

2. 拷贝 应用 所有数据
  cp -a /free_cicdfs0/data/owncloud_wuhan/owncloud/*  /free_cicdfs0/data/owncloud_mysql_wuhan/owncloud

3. 同步数据库
  sqlite3 /free_cicdfs0/data/owncloud_wuhan/owncloud/data/owncloud.db .dump > /free_cicdfs0/data/owncloud.sql

4. 还原配置文件

cat > /free_cicdfs0/data/owncloud_mysql_wuhan/owncloud/config/config.php <<"EOF"
<?php
$CONFIG = array (
  'instanceid' => 'ocdu4htlctd3',
  'passwordsalt' => 'i5uSyuBogucYArNC/on8d2w4sBrXM2',
  'secret' => 'lA+U5are/CQZkIHcv5gaAslRESAMBUvV4d6BiZRi87HLC/IM',
  'trusted_domains' =>
  array (
    0 => '192.168.99.100:50002',
  ),
  'datadirectory' => '/var/www/html/data',
  'overwrite.cli.url' => 'http://192.168.99.100:50002',
  'dbtype' => 'mysql',
  'version' => '10.0.10.4',
  'dbname' => 'owncloud',
  'dbhost' => 'owncloud-mysql',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_admin',
  'dbpassword' => '6EdenAkcQHby0ghLJPKBKnnA1qxrTf',
  'mysql.utf8mb4' => true,
  'logtimezone' => 'UTC',
  'ldapIgnoreNamingRules' => false,
  'installed' => true,
);
EOF
rsync -avz --delete ./owncloud_wuhan/owncloud/ ./owncloud_mysql_wuhan/owncloud/

nohup rsync -avzW --delete ./owncloud_wuhan/owncloud/ ./owncloud_mysql_wuhan/owncloud/  2>&1 > copy.log

ldap config
 

192.168.99.100
cn=admin,dc=example,dc=org

brysjhhrhL356126155165352237656123165615

dc=example,dc=org

✔

# 用户
(|(objectclass=inetOrgPerson)(objectclass=posixAccount)(objectclass=top))

# 登录属性
(&(|(objectclass=inetOrgPerson)(objectclass=posixAccount)(objectclass=top))(|(sn=%uid)))


# 群组
(&(|(objectclass=posixGroup)(objectclass=top))(|(cn=Administrators)(cn=user)))

# 高级- 目录设置
用户显示名称字段
cn

第二用户显示名称字段

基础用户树
dc=example,dc=org

用户搜索属性
可选;每行一个属性

Each attribute value is truncated to 191 characters

组显示名称字段
cn

基础组树
dc=example,dc=org

群组搜索属性
可选;每行一个属性

组成员关联
memberUid

动态组成员URL

# 特殊属性
1t

# 专家- 超越 uuid 检测
cn
cn


compose 部署

https://doc.owncloud.org/server/10.0/admin_manual/installation/docker

docker-env

ownloud_url=192.168.99.111

OWNCLOUD_DOMAIN=localhost

cat << EOF > .env
HTTP_PORT=192.168.99.111:8080
OWNCLOUD_VERSION=latest
OWNCLOUD_DOMAIN=localhost
ADMIN_USERNAME=admin
ADMIN_PASSWORD=brysjhhrhL356126155165352237656123165615


base_dir=/free_cicdfs0/data/owncloud_mysql_redis_wuhan
files=${base_dir}/files
mysql=${base_dir}/mysql
redis=${base_dir}/redis

EOF

docker-compose

version: "3"

services:
  owncloud:
    image: owncloud/server
    container_name: owncloud_server
    restart: always
    ports:
      - ${HTTP_PORT}:8080
    depends_on:
      - mariadb
      - redis
    environment:
      - OWNCLOUD_DOMAIN=${OWNCLOUD_DOMAIN}
      - OWNCLOUD_DB_TYPE=mysql
      - OWNCLOUD_DB_NAME=owncloud
      - OWNCLOUD_DB_USERNAME=owncloud
      - OWNCLOUD_DB_PASSWORD=owncloud
      - OWNCLOUD_DB_HOST=mariadb
      - OWNCLOUD_ADMIN_USERNAME=${ADMIN_USERNAME}
      - OWNCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD}
      - OWNCLOUD_MYSQL_UTF8MB4=true
      - OWNCLOUD_REDIS_ENABLED=true
      - OWNCLOUD_REDIS_HOST=redis
    healthcheck:
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - ${files}:/mnt/data

  mariadb:
    image: mariadb:10.5
    container_name: owncloud_mariadb
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=owncloud
      - MYSQL_USER=owncloud
      - MYSQL_PASSWORD=owncloud
      - MYSQL_DATABASE=owncloud
    command: ["--max-allowed-packet=128M", "--innodb-log-file-size=64M"]
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-u", "root", "--password=owncloud"]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - ${mysql}:/var/lib/mysql

  redis:
    image: redis:6
    container_name: owncloud_redis
    restart: always
    command: ["--databases", "1"]
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - ${redis}:/data

迁移 用户 数据
 

docker exec -u www-data  -ti  9054a239a5e3  bash

php occ files:scan --all


docker exec -u www-data  -ti  owncloudmysqlwuhan_owncloud-wuhan_1  php occ files:scan --all


[root@node01 files]# docker exec -u www-data  -ti bace639882fa entrypoint bash

www-data@bace639882fa: ~/owncloud #  php occ files:scan
Please specify the user id to scan, "--all" to scan for all users or "--path=..."

www-data@bace639882fa: ~/owncloud #  php occ files:scan --all

Scanning files for 1 users
Starting scan for user 1 out of 1 (admin)

+---------+-------+--------------+------------------+
| Folders | Files | Elapsed time | Items per second |
+---------+-------+--------------+------------------+
| 10      | 14    | 00:00:00     | 476              |
+---------+-------+--------------+------------------+
# 上传 数据 到 指定 用户 文件夹, 之后 同步数据
\cp -a /free_cicdfs0/data/owncloud_mysql_wuhan/owncloud/data/admin/files/*  /free_cicdfs0/data/owncloud_mysql_redis_wuhan/files/files/admin/files/

# 务必 通过 entrypoint bash 进入 owncloud 容器 , 否则   php occ 会 缺少 某些 环境变量
docker exec -u www-data  -ti bace639882fa entrypoint bash

php occ files:scan --all


图标 更换

server 版本 图标 替换

container_name='3f6e99e7ac9866416687b36f46632ee1eac034de48200cb615c2755f369f0d2c'

base_path='/var/www/owncloud'

for log_path in "${base_path}/apps/theme-enterprise/core/img/logo-icon.svg" \
"${base_path}/core/img/logo-icon.svg" \
"${base_path}/updater/pub/img/logo-icon.svg" \
"${base_path}/core/img/logo.svg" \
"${base_path}/apps/theme-enterprise/core/img/logo.svg" \
"${base_path}/updater/pub/img/logo.svg"

do 

docker cp -a  /free_cicdfs0/img/logo.svg  ${container_name}:${log_path}

done 

docker exec -u www-data  -ti ${container_name} entrypoint bash


grep  'ownCloud'  -r /var/www/owncloud | awk -F ':' '{print $1}' | xargs -I {} sed -i 's/ownCloud/zOceanNAS/g' {}
# sed: can't read Binary file ${base_path}/core/skeleton/ownCloud Manual.pdf matches: No such file or directory

精简版 版本 图标 替换

find / -name '*logo.svg'
/usr/src/owncloud/core/img/logo.svg
/usr/src/owncloud/updater/pub/img/logo.svg
/var/www/html/updater/pub/img/logo.svg
/var/www/html/core/img/logo.svg

container_name='576e5dc51755ef2c4bf3354dd8ac43edf6f08d2a7371727fba0729a4cbccd56d'

base_path='/var/www/html'

for log_path in "${base_path}/apps/theme-enterprise/core/img/logo-icon.svg" \
"${base_path}/core/img/logo-icon.svg" \
"${base_path}/updater/pub/img/logo-icon.svg" \
"${base_path}/core/img/logo.svg" \
"${base_path}/apps/theme-enterprise/core/img/logo.svg" \
"${base_path}/updater/pub/img/logo.svg"

do 

docker cp -a  /free_cicdfs0/img/logo.svg  ${container_name}:${log_path}

done 

docker exec -u www-data  -ti ${container_name}  bash


grep  'ownCloud'  -r /var/www/ | awk -F ':' '{print $1}' | xargs -I {} sed -i 's/ownCloud/zOceanNAS/g' {}
# sed: can't read Binary file ${base_path}/core/skeleton/ownCloud Manual.pdf matches: No such file or directory


修改 上传 限制

# 添加 一下 属性
vi  /free_cicdfs0/data/owncloud_mysql_wuhan/owncloud/config/config.php

 * Default is 50
 * Set to -1 for no limit
 */
'preview_max_filesize_image' => 50,


 * Value represents the maximum filesize in megabytes. Default is ``10``. Set to
 * ``-1`` for no limit.
 */
'max_filesize_animated_gifs_public_sharing' => 10,

# demo
cat >  /free_cicdfs0/data/owncloud_mysql_wuhan/owncloud/config/config.php  <<"EOF"
<?php
$CONFIG = array (
  'instanceid' => 'ocdu4htlctd3',
  'passwordsalt' => 'i5uSyuBogucYArNC/on8d2w4sBrXM2',
  'secret' => 'lA+U5are/CQZkIHcv5gaAslRESAMBUvV4d6BiZRi87HLC/IM',
  'trusted_domains' =>
  array (
    0 => '192.168.99.100:50000',
    1 => '119.36.243.58:50000',
    2 => 'one-k.xyz:50000',
  ),
  'preview_max_filesize_image' => -1,
  'max_filesize_animated_gifs_public_sharing' => -1,
  'datadirectory' => '/var/www/html/data',
  'overwrite.cli.url' => 'http://192.168.99.100:50000',
  'dbtype' => 'mysql',
  'version' => '10.0.10.4',
  'dbname' => 'owncloud',
  'dbhost' => 'owncloud-mysql',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_admin',
  'dbpassword' => '6EdenAkcQHby0ghLJPKBKnnA1qxrTf',
#  'mysql.utf8mb4' => true,
  'logtimezone' => 'UTC',
  'ldapIgnoreNamingRules' => false,
  'installed' => true,
);

EOF

修改 文件 限制 后  上传 大文件

cd /free_cicdfs0/data/owncloud_mysql_wuhan/owncloud/data/_free_cicdkitqa_9523/files/share_guest
inner_ip='one-k.xyz'

curl  --progress-bar -o ./progress.log -u free_cicdkitqa:free_cicdkitqa@wuhan.123 -T winslaver1.raw   "http://${inner_ip}:50000/remote.php/dav/files/_free_cicdkitqa_9523/share_guest/winslaver2_test_change_limit.raw"

同步文件

docker exec -u www-data  -ti  owncloudmysqlwuhan_owncloud-wuhan_1  php occ files:scan --all

# 添加 定时任务
crontab -l
*/1 * * * * /bin/bash -c "docker exec -u www-data  -i  owncloudmysqlwuhan_owncloud-wuhan_1  php occ files:scan --all"


# 查看 定时 任务是否执行
tail -n 100 /var/log/cron
# Aug 31 12:11:01 node01 CROND[2456144]: (root) CMD (/bin/bash -c "docker exec -u www-data  -i  owncloudmysqlwuhan_owncloud-wuhan_1  php occ files:scan --all")
# Aug 31 12:11:01 node01 CROND[2456145]: (root) CMD (sleep 21 &&  /usr/local/zabbix/timer.sh)


# 查看 执行的 具体 内容
tail -n 50 /var/spool/mail/root


 

​​​​​​​
欢迎大家一起交流呀
qq群:3638803451
vx:wxid_sgdelhiwombj12

 类似资料: