> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://wiki.leviia.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# S3cmd: make a full backup of Nextcloud on your Leviia object storage space (S3 compatible)

# Prerequisites
* [Have created a bucket](https://wiki.leviia.com/en/article/create-a-bucket-on-your-leviia-dashboard-h47vp5/)
* [Have configured and installed s3cmd](https://wiki.leviia.com/en/article/s3cmd-configuration-and-use-hiwyiq/)

# Configuration and backup
* Switch nextcloud to maintenance mode
`sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --on`

* Make a database dump
`mysqldump --single-transaction -h localhost -u <user_db> -p <password_db> <name_db> > nextcloud.sql`

* Send dump to S3
`s3cmd put nextcloud.sql s3://<bucket_name>/nextcloud.sql`

* Send nextcloud data to S3
`s3cmd sync --recursive --preserve --exclude '*/cache/*' /data/nextcloud s3://<bucket_name>/`

* Check contents 
`s3cmd ls <bucket_name>`

* Remove maintenance mode
`sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --off`
