fix first pass
This commit is contained in:
parent
c5a1ac0551
commit
ffd9bf3d39
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@
|
|||||||
*.swp
|
*.swp
|
||||||
*~
|
*~
|
||||||
*.pyc
|
*.pyc
|
||||||
|
__pycache__/*
|
||||||
/tasks.sqlite
|
/tasks.sqlite
|
||||||
/tasks.sqlite-wal
|
/tasks.sqlite-wal
|
||||||
/srvinstallation
|
/srvinstallation
|
||||||
|
23
Dockerfile
Executable file
23
Dockerfile
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
FROM python:3.12-slim
|
||||||
|
|
||||||
|
WORKDIR /opt/tisbackup
|
||||||
|
|
||||||
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
COPY . /opt/tisbackup
|
||||||
|
|
||||||
|
RUN apt update \
|
||||||
|
&& apt install --no-install-recommends -y rsync ssh cron \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN /usr/local/bin/python3.12 -m pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
RUN mkdir -p /var/spool/cron/crontabs \
|
||||||
|
&& echo '59 03 * * * root /bin/bash /opt/tisbackup/backup.sh' > /etc/crontab \
|
||||||
|
&& echo '' >> /etc/crontab \
|
||||||
|
&& crontab /etc/crontab
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
CMD ["/usr/local/bin/python3.12","/opt/tisbackup/tisbackup_gui.py"]
|
||||||
|
|
42
compose.yml
Executable file
42
compose.yml
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
services:
|
||||||
|
tisbackup_gui:
|
||||||
|
container_name: tisbackup_gui
|
||||||
|
image: "tisbackup:latest"
|
||||||
|
build: .
|
||||||
|
volumes:
|
||||||
|
- ./config/:/etc/tis/
|
||||||
|
- ./backup/:/backup/
|
||||||
|
- /etc/timezone:/etc/timezone:ro
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- 9980:8080
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: 0.50
|
||||||
|
memory: 512M
|
||||||
|
reservations:
|
||||||
|
cpus: 0.25
|
||||||
|
memory: 128M
|
||||||
|
tisbackup_cron:
|
||||||
|
container_name: tisbackup_cron
|
||||||
|
image: "tisbackup:latest"
|
||||||
|
build: .
|
||||||
|
volumes:
|
||||||
|
- ./config/:/etc/tis/
|
||||||
|
- ./ssh/:/config_ssh/
|
||||||
|
- ./backup/:/backup/
|
||||||
|
- /etc/timezone:/etc/timezone:ro
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
restart: always
|
||||||
|
command: "/bin/bash /opt/tisbackup/cron.sh"
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: 0.50
|
||||||
|
memory: 512M
|
||||||
|
reservations:
|
||||||
|
cpus: 0.25
|
||||||
|
memory: 128M
|
||||||
|
|
13
config.py
Normal file → Executable file
13
config.py
Normal file → Executable file
@ -1,10 +1,9 @@
|
|||||||
import os,sys
|
import os
|
||||||
from huey.backends.sqlite_backend import SqliteQueue,SqliteDataStore
|
import sys
|
||||||
from huey.api import Huey, create_task
|
|
||||||
|
|
||||||
|
from huey.contrib.sql_huey import SqlHuey
|
||||||
|
from huey.storage import SqliteStorage
|
||||||
|
|
||||||
tisbackup_root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__)))
|
tisbackup_root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__)))
|
||||||
tasks_db = os.path.join(tisbackup_root_dir,"tasks.sqlite")
|
tasks_db = os.path.join(tisbackup_root_dir, "tasks.sqlite")
|
||||||
queue = SqliteQueue('tisbackups',tasks_db)
|
huey = SqlHuey(name="tisbackups",filename=tasks_db,always_eager=False,storage_class=SqliteStorage)
|
||||||
result_store = SqliteDataStore('tisbackups',tasks_db)
|
|
||||||
huey = Huey(queue,result_store,always_eager=False)
|
|
||||||
|
4
cron.sh
Executable file
4
cron.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -x
|
||||||
|
echo "Starting cron job for TIS Backup"
|
||||||
|
cron -f -l 2
|
8
entrypoint.sh
Executable file
8
entrypoint.sh
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
env >> /etc/environment
|
||||||
|
|
||||||
|
# execute CMD
|
||||||
|
echo "$@"
|
||||||
|
exec "$@"
|
||||||
|
|
6
requirements.txt
Normal file → Executable file
6
requirements.txt
Normal file → Executable file
@ -1,3 +1,9 @@
|
|||||||
six
|
six
|
||||||
requests
|
requests
|
||||||
paramiko
|
paramiko
|
||||||
|
pexpect
|
||||||
|
flask
|
||||||
|
simplejson
|
||||||
|
huey
|
||||||
|
iniparse
|
||||||
|
redis
|
||||||
|
6
tasks.py
6
tasks.py
@ -1,6 +1,8 @@
|
|||||||
from huey import RedisHuey
|
|
||||||
import os
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
|
from huey import RedisHuey
|
||||||
|
|
||||||
from tisbackup import tis_backup
|
from tisbackup import tis_backup
|
||||||
|
|
||||||
huey = RedisHuey('tisbackup', host='localhost')
|
huey = RedisHuey('tisbackup', host='localhost')
|
||||||
|
36
tisbackup.py
36
tisbackup.py
@ -18,37 +18,39 @@
|
|||||||
#
|
#
|
||||||
# -----------------------------------------------------------------------
|
# -----------------------------------------------------------------------
|
||||||
import datetime
|
import datetime
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import os,sys
|
import sys
|
||||||
from os.path import isfile, join
|
from os.path import isfile, join
|
||||||
|
|
||||||
tisbackup_root_dir = os.path.dirname(os.path.realpath(__file__))
|
tisbackup_root_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
sys.path.insert(0,os.path.join(tisbackup_root_dir,'lib'))
|
sys.path.insert(0,os.path.join(tisbackup_root_dir,'lib'))
|
||||||
sys.path.insert(0,os.path.join(tisbackup_root_dir,'libtisbackup'))
|
sys.path.insert(0,os.path.join(tisbackup_root_dir,'libtisbackup'))
|
||||||
|
|
||||||
from iniparse import ini,ConfigParser
|
|
||||||
from optparse import OptionParser
|
|
||||||
import re
|
|
||||||
import getopt
|
|
||||||
import os.path
|
|
||||||
import logging
|
|
||||||
import errno
|
import errno
|
||||||
from libtisbackup.common import *
|
import getopt
|
||||||
|
import logging
|
||||||
|
import os.path
|
||||||
|
import re
|
||||||
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
from iniparse import ConfigParser, ini
|
||||||
|
|
||||||
from libtisbackup.backup_mysql import backup_mysql
|
from libtisbackup.backup_mysql import backup_mysql
|
||||||
from libtisbackup.backup_rsync import backup_rsync
|
|
||||||
from libtisbackup.backup_rsync import backup_rsync_ssh
|
|
||||||
#from libtisbackup.backup_oracle import backup_oracle
|
|
||||||
from libtisbackup.backup_rsync_btrfs import backup_rsync_btrfs
|
|
||||||
from libtisbackup.backup_rsync_btrfs import backup_rsync__btrfs_ssh
|
|
||||||
from libtisbackup.backup_pgsql import backup_pgsql
|
|
||||||
from libtisbackup.backup_xva import backup_xva
|
|
||||||
#from libtisbackup.backup_vmdk import backup_vmdk
|
#from libtisbackup.backup_vmdk import backup_vmdk
|
||||||
#from libtisbackup.backup_switch import backup_switch
|
#from libtisbackup.backup_switch import backup_switch
|
||||||
from libtisbackup.backup_null import backup_null
|
from libtisbackup.backup_null import backup_null
|
||||||
from libtisbackup.backup_xcp_metadata import backup_xcp_metadata
|
from libtisbackup.backup_pgsql import backup_pgsql
|
||||||
from libtisbackup.copy_vm_xcp import copy_vm_xcp
|
from libtisbackup.backup_rsync import backup_rsync, backup_rsync_ssh
|
||||||
|
#from libtisbackup.backup_oracle import backup_oracle
|
||||||
|
from libtisbackup.backup_rsync_btrfs import (backup_rsync__btrfs_ssh,
|
||||||
|
backup_rsync_btrfs)
|
||||||
#from libtisbackup.backup_sqlserver import backup_sqlserver
|
#from libtisbackup.backup_sqlserver import backup_sqlserver
|
||||||
from libtisbackup.backup_samba4 import backup_samba4
|
from libtisbackup.backup_samba4 import backup_samba4
|
||||||
|
from libtisbackup.backup_xcp_metadata import backup_xcp_metadata
|
||||||
|
from libtisbackup.backup_xva import backup_xva
|
||||||
|
from libtisbackup.common import *
|
||||||
|
from libtisbackup.copy_vm_xcp import copy_vm_xcp
|
||||||
|
|
||||||
__version__="2.0"
|
__version__="2.0"
|
||||||
|
|
||||||
|
@ -17,30 +17,32 @@
|
|||||||
# along with TISBackup. If not, see <http://www.gnu.org/licenses/>.
|
# along with TISBackup. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
# -----------------------------------------------------------------------
|
# -----------------------------------------------------------------------
|
||||||
import os,sys
|
import os
|
||||||
|
import sys
|
||||||
from os.path import isfile, join
|
from os.path import isfile, join
|
||||||
|
|
||||||
tisbackup_root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__)))
|
tisbackup_root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__)))
|
||||||
sys.path.append(os.path.join(tisbackup_root_dir,'lib'))
|
sys.path.append(os.path.join(tisbackup_root_dir,'lib'))
|
||||||
sys.path.append(os.path.join(tisbackup_root_dir,'libtisbackup'))
|
sys.path.append(os.path.join(tisbackup_root_dir,'libtisbackup'))
|
||||||
|
|
||||||
|
|
||||||
from shutil import *
|
|
||||||
from iniparse import ConfigParser,RawConfigParser
|
|
||||||
from libtisbackup.common import *
|
|
||||||
import time
|
|
||||||
from flask import request, Flask, session, g, appcontext_pushed, redirect, url_for, abort, render_template, flash, jsonify, Response
|
|
||||||
from urllib.parse import urlparse
|
|
||||||
import json
|
|
||||||
import glob
|
import glob
|
||||||
import time
|
import json
|
||||||
|
|
||||||
from config import huey
|
|
||||||
from tasks import run_export_backup, get_task, set_task
|
|
||||||
|
|
||||||
from tisbackup import tis_backup
|
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import time
|
||||||
|
from shutil import *
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
from flask import (Flask, Response, abort, appcontext_pushed, flash, g,
|
||||||
|
jsonify, redirect, render_template, request, session,
|
||||||
|
url_for)
|
||||||
|
from iniparse import ConfigParser, RawConfigParser
|
||||||
|
|
||||||
|
from config import huey
|
||||||
|
from libtisbackup.common import *
|
||||||
|
from tasks import get_task, run_export_backup, set_task
|
||||||
|
from tisbackup import tis_backup
|
||||||
|
|
||||||
cp = ConfigParser()
|
cp = ConfigParser()
|
||||||
cp.read("/etc/tis/tisbackup_gui.ini")
|
cp.read("/etc/tis/tisbackup_gui.ini")
|
||||||
|
Loading…
Reference in New Issue
Block a user