mirror of
https://github.com/ZettaIO/restic-compose-backup.git
synced 2025-10-10 12:20:58 +00:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
758c3075f1 | ||
|
9cad6a5c71 | ||
|
4ebe16af14 | ||
|
fd87ddc388 | ||
|
2cbc5aa6fa | ||
|
ffa2dfc119 | ||
|
cfc92b2284 | ||
|
216202dec7 |
@@ -22,8 +22,7 @@ copyright = '2019, Zetta.IO Technology AS'
|
||||
author = 'Zetta.IO Technology AS'
|
||||
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = '0.3.0'
|
||||
|
||||
release = '0.3.3'
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
- Update version in `setup.py`
|
||||
- Update version in `docs/conf.py`
|
||||
- Update version in `restic_compose_backup/__init__.py`
|
||||
- Build and tag image
|
||||
- push: `docker push zettaio/restic-compose-backup:<version>`
|
||||
- Ensure RTD has new docs published
|
||||
@@ -12,9 +13,9 @@ When releasing a bugfix version we need to update the
|
||||
main image as well.
|
||||
|
||||
```bash
|
||||
docker build . --tag zettaio/restic-compose-backup:0.3
|
||||
docker build . --tag zettaio/restic-compose-backup:0.3.1
|
||||
docker build src --tag zettaio/restic-compose-backup:0.3
|
||||
docker build src --tag zettaio/restic-compose-backup:0.3.3
|
||||
|
||||
docker push zettaio/restic-compose-backup:0.3
|
||||
docker push zettaio/restic-compose-backup:0.3.1
|
||||
docker push zettaio/restic-compose-backup:0.3.3
|
||||
```
|
||||
|
1
src/restic_compose_backup/__init__.py
Normal file
1
src/restic_compose_backup/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
__version__ = '0.3.3'
|
@@ -35,7 +35,13 @@ def run(image: str = None, command: str = None, volumes: dict = None,
|
||||
line = ""
|
||||
while True:
|
||||
try:
|
||||
line += next(stream).decode()
|
||||
# TODO: figure out why..
|
||||
# Apparently the stream can be bytes or strings.
|
||||
data = next(stream)
|
||||
if isinstance(data, bytes):
|
||||
line += data.decode()
|
||||
elif isinstance(data, str):
|
||||
line += data
|
||||
if line.endswith('\n'):
|
||||
break
|
||||
except StopIteration:
|
||||
@@ -51,9 +57,9 @@ def run(image: str = None, command: str = None, volumes: dict = None,
|
||||
fd.write('\n')
|
||||
logger.info(line)
|
||||
|
||||
container.wait()
|
||||
container.reload()
|
||||
logger.debug("Container ExitCode %s", container.attrs['State']['ExitCode'])
|
||||
container.stop()
|
||||
container.remove()
|
||||
|
||||
return container.attrs['State']['ExitCode']
|
||||
|
@@ -42,6 +42,10 @@ def main():
|
||||
elif args.action == 'alert':
|
||||
alert(config, containers)
|
||||
|
||||
elif args.action == 'version':
|
||||
import restic_compose_backup
|
||||
print(restic_compose_backup.__version__)
|
||||
|
||||
|
||||
def status(config, containers):
|
||||
"""Outputs the backup config for the compose setup"""
|
||||
@@ -139,13 +143,15 @@ def start_backup_process(config, containers):
|
||||
vol_result = restic.backup_files(config.repository, source='/volumes')
|
||||
logger.debug('Volume backup exit code: %s', vol_result)
|
||||
if vol_result != 0:
|
||||
logger.error('Backup command exited with non-zero code: %s', vol_result)
|
||||
logger.error('Volume backup exited with non-zero code: %s', vol_result)
|
||||
errors = True
|
||||
except Exception as ex:
|
||||
logger.error('Exception raised during volume backup')
|
||||
logger.exception(ex)
|
||||
errors = True
|
||||
|
||||
# back up databases
|
||||
logger.info('Backing up databases')
|
||||
for container in containers.containers_for_backup():
|
||||
if container.database_backup_enabled:
|
||||
try:
|
||||
@@ -161,14 +167,18 @@ def start_backup_process(config, containers):
|
||||
errors = True
|
||||
|
||||
if errors:
|
||||
logger.error('Exit code: %s', errors)
|
||||
exit(1)
|
||||
|
||||
# Only run cleanup if backup was successful
|
||||
result = cleanup(config, container)
|
||||
logger.debug('cleanup exit code: %s', errors)
|
||||
logger.debug('cleanup exit code: %s', result)
|
||||
if result != 0:
|
||||
logger.error('Exit code: %s', result)
|
||||
exit(1)
|
||||
|
||||
logger.info('Backup completed')
|
||||
|
||||
|
||||
def cleanup(config, containers):
|
||||
"""Run forget / prune to minimize storage space"""
|
||||
@@ -205,7 +215,7 @@ def parse_args():
|
||||
parser = argparse.ArgumentParser(prog='restic_compose_backup')
|
||||
parser.add_argument(
|
||||
'action',
|
||||
choices=['status', 'snapshots', 'backup', 'start-backup-process', 'alert', 'cleanup'],
|
||||
choices=['status', 'snapshots', 'backup', 'start-backup-process', 'alert', 'cleanup', 'version'],
|
||||
)
|
||||
parser.add_argument(
|
||||
'--log-level',
|
||||
|
@@ -3,7 +3,7 @@ from setuptools import setup, find_namespace_packages
|
||||
setup(
|
||||
name="restic-compose-backup",
|
||||
url="https://github.com/ZettaIO/restic-compose-backup",
|
||||
version="0.3.0",
|
||||
version="0.3.3",
|
||||
author="Einar Forselv",
|
||||
author_email="eforselv@gmail.com",
|
||||
packages=find_namespace_packages(include=['restic_compose_backup']),
|
||||
|
Reference in New Issue
Block a user