feat: #8 - converted to a lxc hosting
This commit is contained in:
29
documentation/issue#8.md
Normal file
29
documentation/issue#8.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Feature - Migrate to LXC container
|
||||
|
||||
_[Issue 8](https://git.limbosolutions.com/limbosolutions.com/git.limbosolutions.com/issues/8)_
|
||||
|
||||
## Development & Testing
|
||||
|
||||
- [x] Create LXC Container
|
||||
- [x] Documentation Scripts for Setup
|
||||
- [x] Scripts for Setup
|
||||
- [ ] Restore Backup
|
||||
- [ ] Documentation for backup and restore
|
||||
- [ ] Validate Backup
|
||||
- [x] Recreate System from scripts
|
||||
|
||||
## Day 1
|
||||
|
||||
- [ ] Backup Current Production
|
||||
- [ ] Stop Current Production
|
||||
- [ ] Restore to new Production
|
||||
- [ ] Change DNS Servers
|
||||
- [ ] Check OK
|
||||
- [ ] Production - Reativate Backup
|
||||
- [ ] Production - Execute Backup
|
||||
- [ ] Production - Check Backup
|
||||
|
||||
## Day 2
|
||||
|
||||
- [ ] Production - Check Daily Backup
|
||||
- [ ] Delete Old Production
|
||||
65
documentation/setup-lxc.md
Normal file
65
documentation/setup-lxc.md
Normal file
@@ -0,0 +1,65 @@
|
||||
# LXC Setup
|
||||
|
||||
## Install
|
||||
|
||||
### Requirements
|
||||
|
||||
- Currently hosted using macvlan network
|
||||
- Instructions are provided for $LXC_PROFILE defined as macvlan
|
||||
_For more information how to setup a lxc profile with macvlan network https://git.limbosolutions.com/kb/lxc_
|
||||
|
||||
|
||||
Replace and execute on bash
|
||||
|
||||
```bash
|
||||
LXC_CONTAINER_NAME=gitsrv01
|
||||
LXC_PROFILE=default
|
||||
```
|
||||
|
||||
then execute
|
||||
|
||||
```bash
|
||||
## Create ubuntu container
|
||||
lxc launch ubuntu $LXC_CONTAINER_NAME -p $LXC_PROFILE
|
||||
|
||||
## Setup container for docker
|
||||
curl -s "https://git.limbosolutions.com/kb/lxc/raw/branch/main/scripts/lxc-config-docker-requirements.sh" | bash -s $LXC_CONTAINER_NAME
|
||||
|
||||
|
||||
## update ubuntu container
|
||||
lxc exec $LXC_CONTAINER_NAME -- bash -c "apt update -y && apt upgrade -y"
|
||||
|
||||
## Install fuse and docker on lxc container
|
||||
lxc exec $LXC_CONTAINER_NAME -- bash -c "curl -s \"https://git.limbosolutions.com/kb/docker/raw/branch/main/scripts/ubuntu-fuse-setup.sh\" | bash"
|
||||
|
||||
## Check docker for fusefs
|
||||
lxc exec $LXC_CONTAINER_NAME -- bash -c "docker info"
|
||||
|
||||
#Setup Portainer
|
||||
lxc exec $LXC_CONTAINER_NAME -- bash -c "curl -s \"https://git.limbosolutions.com/kb/portainer/raw/branch/main/scripts/setup.sh\" | bash"
|
||||
|
||||
#confirm container ip address
|
||||
lxc exec $LXC_CONTAINER_NAME -- bash -c "ip a"
|
||||
|
||||
lxc restart $LXC_CONTAINER_NAME
|
||||
|
||||
```
|
||||
|
||||
### Check instalation
|
||||
|
||||
From other computer
|
||||
|
||||
```bash
|
||||
ping $LXC_CONTAINER_NAME
|
||||
```
|
||||
|
||||
Access portainer (https://$LXC_CONTAINER_NAME:9443/) for inicial setup:
|
||||
|
||||
- Setup administration username and password
|
||||
|
||||
## Remove
|
||||
|
||||
```bash
|
||||
lxc rm $LXC_CONTAINER_NAME --force
|
||||
```
|
||||
|
||||
104
documentation/setup.md
Normal file
104
documentation/setup.md
Normal file
@@ -0,0 +1,104 @@
|
||||
# Setup
|
||||
|
||||
## Install
|
||||
|
||||
Setup assumes that I don't have access to the host except through Portainer.
|
||||
|
||||
This demonstrates that access to docker is the only real requirement to host git.limbosolutions.com
|
||||
|
||||
### Requirements
|
||||
|
||||
- Docker
|
||||
_Currently hosted on an ubuntu lxc container with docker and portainer [+ information](setup-lxc.md)._
|
||||
- On instructions replace githost with host ip or address
|
||||
|
||||
### Services (Stacks)
|
||||
|
||||
If portainer installed use portainer (https://githost:9443) to setup/manage services
|
||||
|
||||
Required environment variables (.env):
|
||||
|
||||
```bash
|
||||
GITEA_APP_DATA-VOLUME_NAME=gitea_app_data
|
||||
GITEA_DB_DATA_VOLUME_NAME=gitea_db_data
|
||||
GITEA_DB-DUMPS_VOLUME_NAME=gitea_db-dumps
|
||||
DEFAULT_NETWORK_NAME=gitea_default
|
||||
# gitea mysql dbname
|
||||
DB_NAME=??
|
||||
# gitea mysql user
|
||||
DB_USER=??
|
||||
# gitea mysql password
|
||||
DB_PASSWORD=??
|
||||
# gitea mysql root password
|
||||
DB_ROOT_PASSWORD=??
|
||||
#git tea access port
|
||||
GITEA_PORT=80
|
||||
#duplicati access port
|
||||
DUPLICATI_PORT=8200
|
||||
```
|
||||
|
||||
#### Gitea
|
||||
|
||||
_[Docker Compose File](../docker/gitea-docker-compose.yaml)_
|
||||
|
||||
#### Duplicati
|
||||
|
||||
Requirements:
|
||||
|
||||
- [Duplicati Image with mySql client](https://git.limbosolutions.com/kb/duplicati/src/branch/main/docker/mysqlclient/README.md)
|
||||
|
||||
|
||||
_[Docker Compose File](../docker/dupliticati-docker-compose.yaml)_
|
||||
|
||||
After starting stack:
|
||||
|
||||
- Access duplicati (http://ipaddress:8200) and set a password
|
||||
|
||||
|
||||
## Restore
|
||||
|
||||
### Requirements
|
||||
|
||||
- Host setup with docker and portainer [+ information](setup.md)
|
||||
|
||||
### Process
|
||||
|
||||
1) Recreate stack gitea _[Docker Compose](../docker/docker-compose.yaml)_ removing read only restrictions on duplicati volumes
|
||||
1) Check every Container is ok and running
|
||||
1) Stop every Container except duplicati and portainer
|
||||
_note: restore of portainer/duplicati not tested_
|
||||
1) Enter Duplicati (http://hostip:8200)
|
||||
1) Import Backup job (if not possible next steps must be adapted)
|
||||
- Restore with permissions checked
|
||||
- All Imported jobs schedules must be disabled (or disable write permissions on backup host)
|
||||
1) Recreate duplicati local database (home-> backup-> advanced-> database-> Recreate (delete and repair))
|
||||
1) Restore all files (except portainer and duplicati data) to original location
|
||||
- If database engine is diferent do not restore db_data and check restore database **before next steps**with this processs because duplicati is running!
|
||||
1) Recreate stack gitea _[Docker Compose](../docker/docker-compose.yaml)_ with original read only restrictions on duplicati volumes
|
||||
1) Confirm everything is ok and running
|
||||
1) Return to duplicati on schedule job add script to run-script-before-required /data/myScripts/backupdb.sh
|
||||
1) Execute a backup
|
||||
1) Reenable Scheduling
|
||||
|
||||
### Database
|
||||
|
||||
Only required if database data files not recovarable. (Example: diferent database engine from backup)
|
||||
|
||||
1) Start Portainer container (if stopped in restore process)
|
||||
2) Start Database container (if stopped in restore process)
|
||||
3) Enter Database container bash (by using portainer)
|
||||
4) Execute:
|
||||
|
||||
```bash
|
||||
#select a file to import
|
||||
ls /db-dumps
|
||||
#select a file to import
|
||||
DB_FILE= "file name to import"
|
||||
#
|
||||
mysql --host db -uroot -p ${MYSQL_DATABASE} < /db-dumps/$DB_FILE
|
||||
#enter root password (root password is in enviromnent variable ${MYSQL_ROOT_PASSWORD})
|
||||
```
|
||||
|
||||
### network related
|
||||
|
||||
If ip changed. change dns servers (git.lan) and reverse proxy (git.limbosoluttions.com) to new ip.
|
||||
Reference in New Issue
Block a user