ShahriyarR / MySQL-AutoXtraBackup

MySQL-AutoXtraBackup commandline tool written in Python 3 based on Percona XtraBackup
https://autoxtrabackup.azepug.az/
MIT License
141 stars 78 forks source link

Process quits with error while cleaning up old archives #252

Closed prox2k closed 6 years ago

prox2k commented 6 years ago

Archive Configuration is: archive_dir=/backup/mysql/n1/archive prepare_archive=1 move_archive=1 full_backup_interval=2 day

Script quits with an format error

2018-01-09 07:34:22 DEBUG <pid.PidFile object at 0x7f012f5e0228> entering setup 2018-01-09 07:34:22 DEBUG <pid.PidFile object at 0x7f012f5e0228> create pidfile: /tmp/MySQL-AutoXtraBackup/autoxtrabackup.pid 2018-01-09 07:34:23 DEBUG <pid.PidFile object at 0x7f012f5e0228> check pidfile: /tmp/MySQL-AutoXtraBackup/autoxtrabackup.pid 2018-01-09 07:34:23 DEBUG Running mysqladmin command -> /usr/bin/mysqladmin --defaults-file=/etc/mysql/n1/my.cnf --user=root --password=97112319131080 status --socket=/var/run/mysqld/n1/mysqld.sock 2018-01-09 07:34:23 DEBUG OK: Server is Up and running 2018-01-09 07:34:23 DEBUG OK: /usr/bin/mysql exists 2018-01-09 07:34:23 DEBUG OK: /usr/bin/mysqladmin exists 2018-01-09 07:34:23 DEBUG OK: MySQL configuration file exists 2018-01-09 07:34:23 DEBUG OK: XtraBackup exists 2018-01-09 07:34:23 DEBUG OK: Main backup directory exists 2018-01-09 07:34:23 DEBUG OK: Full Backup directory exists 2018-01-09 07:34:23 DEBUG OK: Increment directory exists 2018-01-09 07:34:23 DEBUG OK: Archive folder directory exists 2018-01-09 07:34:23 DEBUG OK: Check status 2018-01-09 07:34:23 DEBUG - - - - Your full backup is timeout : Taking new Full Backup! - - - - 2018-01-09 07:34:23 DEBUG Starting cleaning of old archives 2018-01-09 07:34:23 DEBUG <pid.PidFile object at 0x7f012f5e0228> closing pidfile: /tmp/MySQL-AutoXtraBackup/autoxtrabackup.pid Traceback (most recent call last): File "/usr/local/bin/autoxtrabackup", line 9, in load_entry_point('mysql-autoxtrabackup==1.5.1', 'console_scripts', 'autoxtrabackup')() File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 722, in call return self.main(args, kwargs) File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke return callback(args, *kwargs) File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 17, in new_func return f(get_current_context(), args, **kwargs) File "/usr/local/lib/python3.4/dist-packages/mysql_autoxtrabackup-1.5.1-py3.4.egg/autoxtrabackup.py", line 239, in all_procedure b.all_backup() File "/usr/local/lib/python3.4/dist-packages/mysql_autoxtrabackup-1.5.1-py3.4.egg/master_backup_script/backuper.py", line 846, in all_backup self.clean_old_archives() File "/usr/local/lib/python3.4/dist-packages/mysql_autoxtrabackup-1.5.1-py3.4.egg/master_backup_script/backuper.py", line 253, in clean_oldarchives archive, "%Y-%m-%d%H-%M-%S.tar.gz") File "/usr/lib/python3.4/_strptime.py", line 500, in _strptime_datetime tt, fraction = _strptime(data_string, format) File "/usr/lib/python3.4/_strptime.py", line 337, in _strptime (data_string, format)) ValueError: time data '2018-01-03_04-30-04archive' does not match format '%Y-%m-%d%H-%M-%S.tar.gz' 2018-01-09 07:34:24 DEBUG <pid.PidFile object at 0x7f012f5e0228> closing pidfile: /tmp/MySQL-AutoXtraBackup/autoxtrabackup.pid

ShahriyarR commented 6 years ago

That's weird. Now looking at.

ShahriyarR commented 6 years ago

I have spotted the reason:

ValueError: time data '2018-01-03_04-30-04_archive' does not match format '%Y-%m-%d%H-%M-%S.tar.gz'

So it is related to:

        for archive in self.sorted_ls(self.archive_dir):
            archive_date = datetime.strptime(
                archive, "%Y-%m-%d_%H-%M-%S.tar.gz")

It is looking for .tar.gz file but not for _archive one which is recently added.

ShahriyarR commented 6 years ago

@prox2k could you please test the bugfix_issue252 branch to see if it works? I have no chance to test it right now.

prox2k commented 6 years ago

@ShahriyarR I did test the fix and it works for me!

ShahriyarR commented 6 years ago

Nice very nice :) Now merging it to release_v1.5.2 thanks for report.