使用筆記
android 同步CardDav CALDAV方式
- 安裝f-droid
- 從f-droid安裝davx5
- 安裝tasks
當user因密碼錯誤過多導致disable時
方法1 改資料庫
UPDATE oc_preferences SET configvalue = 'true' WHERE appid = 'core' AND configkey = 'enabled' AND userid = 'user_id'
方法2 php指令
sudo -u www-data php occ user:enable user_id
出現locked 423問題
方法一:在config.php加入'filelockinf.enabled'=>false,
方法二:
- config.php 'maintance'=>ture;
- Delete from oc_file_locks where 1;
- config.php 'maintance'=>false;
無法使用local nolyoffice server的問題
會出現Error when trying to connect (Host violates local access rules)的錯誤訊息
vi config/config.php
'allow_local_remote_servers' => true, 加入這行
不要在通訊錄顯示其他人的資料
安裝app customer CSS然後加上
#contactsmenu {
display: none;
}
使用程式同步大資料時造成timeout
1、php.ini 中的“upload_max_filesize” “post_max_size” and “memory_limit” 設定不夠
2、nginx中的client_max_body_size、client_body_timeout、fastcgi_buffers 設定不夠
3、clamav掃描上傳過大檔案所致
cron.php 失敗的原因
管理者登入nextcloud會在設定-基本設定頁面提示上次執行背景工作已經超過xx小時
使用cmd執行sudo -u www-data php -f 路徑/cron.php 會出現以下訊息
PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 438272 bytes) in /home/ronfs/nextcloud/fs.dreamteenet.com/3rdparty/composer/autoload_real.php on line 37 的訊息
將php.ini 的memory_limit 改成-1(沒有限制)
使用carddav同步
網址範例:https://cloud.nextcloud.com/remote.php/dav/calendars/daniel/personal/
使用webdav同步
網址範例:davs://example.com/nextcloud/remote.php/dav/files/USERNAME/
https://cloud.YOURDOMAIN.com/remote.php/dav/files/USERNAME/
windows:
net use Z: https://example.com/nextcloud/remote.php/dav/files/USERNAME/ /user:youruser yourpassword
Since WebDAV is an extension of HTTP, cURL can be used to script file operations.
Note
Settings → Administration → Sharing → Allow users on this server to send shares to other servers.
If this option is disabled the option --header "X-Requested-With: XMLHttpRequest" needs to be passed to cURL.
To create a folder with the current date as name:
$ curl -u user:pass -X MKCOL "https://example.com/nextcloud/remote.php/dav/files/USERNAME/$(date '+%d-%b-%Y')"
To upload a file error.log into that directory:
$ curl -u user:pass -T error.log "https://example.com/nextcloud/remote.php/dav/files/USERNAME/$(date '+%d-%b-%Y')/error.log"
To move a file:
$ curl -u user:pass -X MOVE --header 'Destination: https://example.com/nextcloud/remote.php/dav/files/USERNAME/target.jpg' https://example.com/nextcloud/remote.php/dav/files/USERNAME/source.jpg
backup & restore
backup
maintenance mode
way1
sudo -u www-data php occ maintenance:mode --on
way2
You may also put your server into this mode by editing config/config.php. Change "maintenance" => false to "maintenance" => true:
<?php
"maintenance" => true,
Don’t forget to change it back to false when you are finished.
folders backup
rsync -Aavx nextcloud/ nextcloud-dirbkp_`date +"%Y%m%d"`/
Database backup
MySQL/MariaDB
MySQL or MariaDB, which is a drop-in MySQL replacement, is the recommended database engine. To backup MySQL/MariaDB:
mysqldump --single-transaction -h [server] -u [username] -p[password] [db_name] > nextcloud-sqlbkp_`date +"%Y%m%d"`.bak
If you use enabled MySQL/MariaDB 4-byte support (Enabling MySQL 4-byte support, needed for emoji), you will need to add --default-character-set=utf8mb4 like this:
mysqldump --single-transaction --default-character-set=utf8mb4 -h [server] -u [username] -p[password] [db_name] > nextcloud-sqlbkp_`date +"%Y%m%d"`.bak
SQLite
sqlite3 data/owncloud.db .dump > nextcloud-sqlbkp_`date +"%Y%m%d"`.bak
PostgreSQL
PGPASSWORD="password" pg_dump [db_name] -h [server] -U [username] -f nextcloud-sqlbkp_`date +"%Y%m%d"`.bak
restore
folder restore
rsync -Aax nextcloud-dirbkp/ nextcloud/
database restore
Warning
Before restoring a backup you need to make sure to delete all existing database tables.
The easiest way to do this is to drop and recreate the database. SQLite does this automatically.
MySQL
MySQL is the recommended database engine. To restore MySQL:
mysql -h [server] -u [username] -p[password] -e "DROP DATABASE nextcloud"
mysql -h [server] -u [username] -p[password] -e "CREATE DATABASE nextcloud"
If you use UTF8 with multibyte support (e.g. for emojis in filenames), use:
mysql -h [server] -u [username] -p[password] -e "DROP DATABASE nextcloud"
mysql -h [server] -u [username] -p[password] -e "CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci"
PostgreSQL
PGPASSWORD="password" psql -h [server] -U [username] -d template1 -c "DROP DATABASE \"nextcloud\";"
PGPASSWORD="password" psql -h [server] -U [username] -d template1 -c "CREATE DATABASE \"nextcloud\";"
Restoring
Note
This guide assumes that your previous backup is called “nextcloud-sqlbkp.bak”
MySQL
MySQL is the recommended database engine. To restore MySQL:
mysql -h [server] -u [username] -p[password] [db_name] < nextcloud-sqlbkp.bak
SQLite
rm data/owncloud.db
sqlite3 data/owncloud.db < nextcloud-sqlbkp.bak
PostgreSQL
PGPASSWORD="password" psql -h [server] -U [username] -d nextcloud -f nextcloud-sqlbkp.bak
Maintenance commands
Use these commands when you upgrade Nextcloud, manage encryption, perform backups and other tasks that require locking users out until you are finished:
maintenance
maintenance:data-fingerprint update the systems data-fingerprint after a backup is restored
maintenance:mimetype:update-db Update database mimetypes and update filecache
maintenance:mimetype:update-js Update mimetypelist.js
maintenance:mode set maintenance mode
maintenance:repair repair this installation
maintenance:theme:update Apply custom theme changes
maintenance:update:htaccess Updates the .htaccess file
sudo -u www-data php occ maintenance:mode --on
sudo -u www-data php occ maintenance:mode --off
sudo -u www-data php occ maintenance:repair
如何讓Nextcloud自動掃描資料
'filesystem_check_changes' => 1 #在config.php增加
php occ files:scan --all #手動掃描所有資料
使用 occ 指令重建 oc_filecache
sudo -u www-data php occ files:scan --all
nextcloud升級後常常需要做的事情
sudo -u www-data php occ db:add-missing-indices
垃圾桶的使用
'trashbin_retention_obligation' => 'auto', #預設,在config.php設定還有以下參數auto
default setting. keeps files and folders in the trash bin for 30 days and automatically deletes anytime after that if space is needed (note: files may not be deleted if space is not needed).
D, auto
keeps files and folders in the trash bin for D+ days, delete anytime if space needed (note: files may not be deleted if space is not needed)
auto, D
delete all files in the trash bin that are older than D days automatically, delete other files anytime if space needed
D1, D2
keep files and folders in the trash bin for at least D1 days and delete when exceeds D2 days (note: files will not be deleted automatically if space is needed)
disabled
trash bin auto clean disabled, files and folders will be kept forever
背景作業
Deactivate background job:
occ config:app:set --value=no files_trashbin background_job_expire_trash
Activate background job:
occ config:app:delete files_trashbin background_job_expire_trash
解鎖ip(因為大量錯誤導致ip被鎖定)
DELETE FROM oc_bruteforce_attempts WHERE ip = "x.x.x.x";
No Comments