Compare commits
31 Commits
main
...
7088008535
| Author | SHA1 | Date | |
|---|---|---|---|
| 7088008535 | |||
| 5785571f48 | |||
| fec022f1be | |||
| 74b13252fe | |||
| c96dfcac5b | |||
| 07412c905f | |||
| 3efef96fa6 | |||
| 6c4cbc7fed | |||
| 49d190081b | |||
| 82a5971502 | |||
| 657b305eef | |||
| f79da09e97 | |||
| 3459ef7101 | |||
| 370d409851 | |||
| 2f66c0cd94 | |||
| c872f7c6cb | |||
| dd36b2b5ba | |||
| b57e15b7d6 | |||
| 88d8ace2e8 | |||
| 2bfc501395 | |||
| 9eb54fc4ca | |||
| fffb6ddfa4 | |||
| d45a9c8d03 | |||
| dbf874fd7f | |||
| 874b2705ce | |||
| 5f28f2ef8a | |||
| 5513b14587 | |||
| 0e7c34489c | |||
| 10f7cf88d2 | |||
| 8628a12ec5 | |||
| dbe6acbf0e |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,4 +1,3 @@
|
||||
**.env
|
||||
_volumes
|
||||
_volumes
|
||||
.vscode
|
||||
*.local/*
|
||||
*.env
|
||||
*.env.d/*
|
||||
15
README.md
15
README.md
@@ -1,10 +1,11 @@
|
||||
|
||||
# git.limbosolutions.com
|
||||
|
||||
* Arquitectura : armv7
|
||||
* docker
|
||||
[compose file](docker/docker-compose.armv7.yaml)
|
||||
|
||||
## Backup and Restore Strategy
|
||||
Duplicati
|
||||
(more info required)
|
||||
|
||||
## Setup
|
||||
|
||||
for more information check /documentation/setup.md
|
||||
|
||||
## Backup Strategy
|
||||
|
||||
Duplicati running on docker.
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
# compose file
|
||||
## Requirements
|
||||
* [Docker Image](https://git.limbosolutions.com/marcio.fernandes/duplicati-utils/src/branch/main/docker/sqlclient.DockerFile)
|
||||
|
||||
|
||||
# old info
|
||||
## Backup
|
||||
/usr/bin/docker exec -u git -w /tmp/backups gitea bash -c "/app/gitea/gitea dump"
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
version: "3"
|
||||
services:
|
||||
server:
|
||||
image: kunde21/gitea-arm
|
||||
container_name: gitea
|
||||
environment:
|
||||
- GITEA__database__DB_TYPE=mysql
|
||||
- GITEA__database__HOST=db:3306
|
||||
- GITEA__database__NAME=${GITEA_DB_NAME}
|
||||
- GITEA__database__USER=${GITEA_DB_USER}
|
||||
- GITEA__database__PASSWD=${GITEA_DB_PASSWORD}
|
||||
- DISABLE_SSH=true
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- data:/data
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
#ports:
|
||||
#- "3000:3000" web ui
|
||||
#- "22:22" ssh
|
||||
depends_on:
|
||||
- db
|
||||
networks:
|
||||
macvlan:
|
||||
ipv4_address: ${GITEA_MACVLAN_IP}
|
||||
gitea_network:
|
||||
db:
|
||||
image: tobi312/rpi-mariadb:10.5-ubuntu
|
||||
container_name: gitea_mariadb
|
||||
restart: always
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD}
|
||||
- MYSQL_USER=${GITEA_DB_USER}
|
||||
- MYSQL_PASSWORD=${GITEA_DB_PASSWORD}
|
||||
- MYSQL_DATABASE=${GITEA_DB_NAME}
|
||||
volumes:
|
||||
- db:/var/lib/mysql
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
networks:
|
||||
gitea_network:
|
||||
duplicati:
|
||||
container_name: gitea_duplicati
|
||||
image: duplicati-sqlclient
|
||||
environment:
|
||||
- GITEA_DB_HOST=db
|
||||
- GITEA_DB_NAME=${GITEA_DB_NAME}
|
||||
- GITEA_DB_USER=${GITEA_DB_USER}
|
||||
- GITEA_DB_PASSWORD=${GITEA_DB_PASSWORD}
|
||||
- GITEA_DB_BACKUP_TARGETFOLDER=${GITEA_DB_BACKUP_TARGETFOLDER}
|
||||
volumes:
|
||||
- duplicati-data:/data
|
||||
- duplicati-data:/git/duplicati-data:ro
|
||||
- data:/git/data:ro
|
||||
- db:/git/db:ro
|
||||
- db-dumps:/git/db-dumps
|
||||
ports:
|
||||
- 8202:8200
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
gitea_network:
|
||||
volumes:
|
||||
data:
|
||||
db:
|
||||
db-dumps:
|
||||
duplicati-data:
|
||||
networks:
|
||||
macvlan:
|
||||
external: true
|
||||
name: macvlan_pub_net
|
||||
gitea_network:
|
||||
30
docker/duplicati-docker-compose.yaml
Normal file
30
docker/duplicati-docker-compose.yaml
Normal file
@@ -0,0 +1,30 @@
|
||||
version: "3"
|
||||
services:
|
||||
duplicati:
|
||||
image: duplicati-sqlclient # requirement https://git.limbosolutions.com/kb/duplicati/src/branch/main/docker/sqlclient.dockerfile
|
||||
environment:
|
||||
- DB_HOST=db
|
||||
- DB_NAME=${DB_NAME}
|
||||
- DB_USER=${DB_USER}
|
||||
- DB_PASSWORD=${DB_PASSWORD}
|
||||
- DB_TARGETFOLDER=/git/db-dumps
|
||||
volumes:
|
||||
- duplicati-data:/data
|
||||
- duplicati-data:/git/duplicati-data:ro
|
||||
- data:/git/data:ro
|
||||
- db:/git/db:ro
|
||||
- db-dumps:/git/db-dumps
|
||||
ports:
|
||||
- 8200:8200
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
duplicati-data:
|
||||
data:
|
||||
name: ${GITEA_APP_VOLUMES_DATA_NAME}
|
||||
db:
|
||||
name: ${GITEA_DB_VOLUMES_DATA_NAME}
|
||||
db-dumps:
|
||||
name: ${GITEA_DB_VOLUMES_DB-DUMPS_NAME}
|
||||
networks:
|
||||
gitea:
|
||||
name: ${DEFAULT_NETWORK_NAME}
|
||||
45
docker/gitea-docker-compose.yaml
Normal file
45
docker/gitea-docker-compose.yaml
Normal file
@@ -0,0 +1,45 @@
|
||||
version: "3"
|
||||
services:
|
||||
app:
|
||||
image: gitea/gitea:1.17
|
||||
environment:
|
||||
- GITEA__database__DB_TYPE=mysql
|
||||
- GITEA__database__HOST=db:3306
|
||||
- GITEA__database__NAME=${DB_NAME}
|
||||
- GITEA__database__USER=${DB_USER}
|
||||
- GITEA__database__PASSWD=${DB_PASSWORD}
|
||||
- DISABLE_SSH=true
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- data:/data
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
ports:
|
||||
- ${APP_PORT}:80
|
||||
networks:
|
||||
- gitea
|
||||
db:
|
||||
image: mysql:8
|
||||
restart: always
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
|
||||
- MYSQL_USER=${DB_USER}
|
||||
- MYSQL_PASSWORD=${DB_PASSWORD}
|
||||
- MYSQL_DATABASE=${DB_NAME}
|
||||
volumes:
|
||||
- db:/var/lib/mysql
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- db-dumps:/db-dumps
|
||||
networks:
|
||||
- gitea
|
||||
volumes:
|
||||
data:
|
||||
name: ${GITEA_APP_DATA-VOLUME_NAME}
|
||||
db:
|
||||
name: ${GITEA_DB_DATA_VOLUME_NAME}
|
||||
db-dumps:
|
||||
name: ${GITEA_DB-DUMPS_VOLUME_NAME}
|
||||
networks:
|
||||
gitea:
|
||||
name: ${DEFAULT_NETWORK_NAME}
|
||||
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
|
||||
62
documentation/setup-lxc.md
Normal file
62
documentation/setup-lxc.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# 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"
|
||||
|
||||
#install 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"
|
||||
|
||||
```
|
||||
|
||||
### Check instalation
|
||||
|
||||
From other computer
|
||||
|
||||
```bash
|
||||
ping http://$LXC_CONTAINER_NAME:9000
|
||||
```
|
||||
|
||||
Access portainer (http://$LXC_CONTAINER_NAME:9000_) for inicial setup:
|
||||
|
||||
- Setup administration username and password
|
||||
|
||||
## Remove
|
||||
|
||||
```bash
|
||||
lxc rm $LXC_CONTAINER_NAME --force
|
||||
```
|
||||
103
documentation/setup.md
Normal file
103
documentation/setup.md
Normal file
@@ -0,0 +1,103 @@
|
||||
# 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 (http://githost:9000) 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/docker/sqlclient/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://githost: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)
|
||||
- (step not required after this migration) Remove references to scripts (example:run-script-before-required, /data/myScripts/backupdb.sh)
|
||||
1) Recreate duplicati local database (home-> backup-> advanced-> database-> Recreate (delete and repair))
|
||||
1) Restore all files to original location
|
||||
- If database engine is diferent do not restore db_data and check restore database **before next steps**
|
||||
- From duplicati only restore custom scripts (duplicati-data/myScripts), dot not restore full duplicati 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})
|
||||
```
|
||||
|
||||
23
scripts/setup-lxc.sh
Normal file
23
scripts/setup-lxc.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
## Create a container
|
||||
lxc launch ubuntu $LXC_CONTAINER_NAME -p $LXC_PROFILE && \
|
||||
|
||||
## Setup container for docker
|
||||
curl - "https://git.limbosolutions.com/kb/lxc/raw/branch/main/scripts/lxc-config-docker-requirements.sh" | bash $LXC_CONTAINER_NAME
|
||||
|
||||
|
||||
## update container
|
||||
lxc exec $LXC_CONTAINER_NAME bash -c "apt update -y && apt upgrade -y"
|
||||
|
||||
## Install 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 "
|
||||
|
||||
#install Portainer
|
||||
lxc exec $LXC_CONTAINER_NAME bash -c "curl -s \"https://git.limbosolutions.com/kb/portainer/raw/branch/main/scripts/setup.sh\" | bash "
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
3
scripts/setup.sh
Normal file
3
scripts/setup.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
chmod +x ./setup-lxc.sh
|
||||
./setup-lxc.sh
|
||||
4
scripts/web-setup.sh
Normal file
4
scripts/web-setup.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
git clone https://git.limbosolutions.com/limbosolutions.com/git.limbosolutions.com
|
||||
chmod +x ./git.limbosolutions.com/scripts/setup.sh
|
||||
./git.limbosolutions.com/scripts/setup.sh
|
||||
Reference in New Issue
Block a user