Yuanji's Wiki

人間は考える葦である

用户工具

站点工具


wiki:install

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

后一修订版
前一修订版
上一修订版 两侧同时换到之后的修订记录
wiki:install [2019/11/16 22:44 JST]
gimo initial
wiki:install [2019/11/17 15:01 JST]
gimo rewrite backup & restore
行 6: 行 6:
  
 ==== Download docker-compose.yml ==== ==== Download docker-compose.yml ====
 +
 +**note: you should edit environment variables to meet your own needs. **
  
 <file yaml docker-compose.yml> <file yaml docker-compose.yml>
行 32: 行 34:
   docker-compose up -d   docker-compose up -d
  
-===== Backup DokuWiki =====+===== Backup DokuWiki's volume =====
  
-==== Download backup script ==== +  docker-compose stop
- +
-<file bash docker_volume_backup.sh> +
-#!/bin/bash +
- +
-compose_file_path=$1 +
-project_name=$2 +
-backup_path=$3 +
- +
-function backup_volume { +
-  volume_name=$1 +
-  backup_destination=$2 +
- +
-  docker run --rm -v $volume_name:/data -v $backup_destination:/backup ubuntu tar -zcvf /backup/$volume_name.tar /data +
-+
- +
-echo "Stopping running containers" +
-docker-compose -f $compose_file_path stop +
- +
-echo "Mounting volumes and performing backup..." +
-volumes=($(docker volume ls -f name=$project_name | awk '{if (NR > 1) print $2}')) +
-for v in "${volumes[@]}" +
-do +
-  backup_volume $v $backup_path +
-done +
- +
-echo "Restarting containers" +
-docker-compose -f $compose_file_path start +
-</file>+
  
-==== Backup DokuWiki's volume ====+  docker run --rm -v dokuwiki_dokuwiki_data:/data -v /opt/dokuwiki/dokuwiki_backup:/backup ubuntu tar -zcvf /backup/dokuwiki_dokuwiki_data.tar /data
  
-  ./docker_volume_backup.sh $compose_file_path dokuwiki $backup_path+===== Restore DokuWiki's volume =====
  
-==== Restore DokuWiki'volume ====+  docker volume create dokuwiki_dokuwiki_data 
 +   
 +  docker run -v dokuwiki_dokuwiki_data:/bitnami --name dummy_dokuwiki ubuntu /bin/bash
  
-  docker run --rm --volumes-from dokuwiki_dokuwiki_1 -v $(pwd):/backup ubuntu bash -c "cd /bitnami && tar xvf /backup/dokuwiki_dokuwiki_data.tar --strip 1"+  docker run --rm --volumes-from dummy_dokuwiki -v $(pwd):/backup ubuntu bash -c "cd /bitnami && tar xvf /backup/dokuwiki_dokuwiki_data.tar --strip 1"
  
  
-===== See also =====+===== References =====
   * [[https://hub.docker.com/r/bitnami/dokuwiki|bitnami/dokuwiki - Docker Hub]]   * [[https://hub.docker.com/r/bitnami/dokuwiki|bitnami/dokuwiki - Docker Hub]]
   * [[https://gist.github.com/kiview/5ff58ed69366e2d591d19ac34d8f8616/|Docker-Compose volume backup]]   * [[https://gist.github.com/kiview/5ff58ed69366e2d591d19ac34d8f8616/|Docker-Compose volume backup]]
   * [[https://docs.docker.com/storage/volumes/#backup-restore-or-migrate-data-volumesUse|volumes | Docker Documentation ]]   * [[https://docs.docker.com/storage/volumes/#backup-restore-or-migrate-data-volumesUse|volumes | Docker Documentation ]]
  
wiki/install.txt · 最后更改: 2019/11/17 20:47 JST 由 gimo