ShahriyarR / MySQL-AutoXtraBackup

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

ERROR [copy_back:159] FileNotFoundError: [Errno 2] No such file or directory: 'None' #455

Closed icy1900 closed 2 years ago

icy1900 commented 2 years ago

2021-11-08 16:56:31 INFO [copy_back:24] Shutting Down MySQL server: 2021-11-08 16:56:31 INFO [process_runner:54] SUBPROCESS STARTING: systemctl start mysql@default.service 2021-11-08 16:56:31 INFO [process_runner:69] SUBPROCESS systemctl COMPLETED with exit code: 0 2021-11-08 16:56:31 INFO [copy_back:50] Moving MySQL data_dir to /tmp/MySQL-AutoXtraBackup-tmp-dir 2021-11-08 16:56:31 INFO [process_runner:54] SUBPROCESS STARTING: rm -rf /tmp/MySQL-AutoXtraBackup-tmp-dir 2021-11-08 16:56:31 INFO [process_runner:69] SUBPROCESS rm COMPLETED with exit code: 0 2021-11-08 16:56:31 ERROR [copy_back:159] FileNotFoundError: [Errno 2] No such file or directory: 'None' 2021-11-08 16:56:31 INFO [autoxtrabackup:301] Xtrabackup command history: 2021-11-08 16:56:31 INFO [autoxtrabackup:303] ['command', 'xtrabackup_function', 'start time', 'end time', 'duration', 'exit code'] 2021-11-08 16:56:31 INFO [autoxtrabackup:303] ['systemctl', 'None', '2021-11-08 16:56:31', '2021-11-08 16:56:31', '0s', '0'] 2021-11-08 16:56:31 INFO [autoxtrabackup:303] ['rm', 'None', '2021-11-08 16:56:31', '2021-11-08 16:56:31', '0s', '0']2021-11-08 16:56:31 INFO [autoxtrabackup:304] Autoxtrabackup completed successfully!

and in the log I can see

2021-11-08 16:56:31 INFO [copy_back:50] Moving MySQL data_dir to /tmp/MySQL-AutoXtraBackup-tmp-dir 2021-11-08 16:56:31 INFO [process_runner:54] SUBPROCESS STARTING: rm -rf /tmp/MySQL-AutoXtraBackup-tmp-dir 2021-11-08 16:56:31 DEBUG [process_runner:103] subprocess args are: ['rm', '-rf', '/tmp/MySQL-AutoXtraBackup-tmp-dir'] 2021-11-08 16:56:31 INFO [process_runner:69] SUBPROCESS rm COMPLETED with exit code: 0 2021-11-08 16:56:31 ERROR [copy_back:159] FileNotFoundError: [Errno 2] No such file or directory: 'None' 2021-11-08 16:56:31 DEBUG [base:220] <pid.posix.PidFile object at 0x7f98507b4f48> closing pidfile: /tmp/MySQL-AutoXtraBackup/autoxtrabackup.pid

I am using version 2.0.2, the backup works ok, but the restore operation seems did nothing to the datadir. I've tried to empty the datadir and put a empty file in it, then try to recover the backup, it report as the above, and the datadir is still with only a empty file

the backup have already been manually prepared

my configuration file

[MySQL]
mysql=/usr/bin/mysql
mycnf=***
mysqladmin=/usr/bin/mysqladmin
mysql_user=***
mysql_password=***
## Set either mysql_socket only, OR host + port. If both are set mysql_socket is used
mysql_socket=***
#mysql_host=127.0.0.1
#mysql_port=3306
datadir=****
[Logging]
#[debug,info,warning,error,critical]
log = DEBUG
log_file_max_bytes = 1073741824
log_file_backup_count = 7
#log_file =

[Backup]
#optional: set pid directory
pid_dir = /tmp/MySQL-AutoXtraBackup
tmp_dir = /tmp/MySQL-AutoXtraBackup-tmp-dir
#optional: set warning if pid of backup us running for longer than x
pid_runtime_warning = 2 Hours
backup_dir = /data/mysql_backup
backup_tool = /usr/bin/xtrabackup
#optional: specify different path/version of xtrabackup here for prepare
#prepare_tool =
xtra_prepare = --apply-log-only
#optional: pass additional options for backup stage
#xtra_backup = --compact
#optional: pass additional options for prepare stage
#xtra_prepare_options = --rebuild-indexes
#optional: pass general additional options; it will go to both for backup and prepare
#xtra_options = --binlog-info=ON --galera-info
#optional: set archive and rotation
#archive_dir = /data/mysql_backup_archives
#prepare_archive = 1
#move_archive = 0
#full_backup_interval = 1 day
#archive_max_size = 100GiB
#archive_max_duration = 4 Days
#optional: warning(enable this if you want to take partial backups). specify database names or table names.
#partial_list = test.t1 test.t2 dbtest

[Compress]
#optional
#enable only if you want to use compression.
#compress = quicklz
#compress_chunk_size = 65536
#compress_threads = 4
#decompress = TRUE
#enable if you want to remove .qp files after decompression.(Available from PXB 2.3.7 and 2.4.6)
#remove_original = FALSE

[Encrypt]
[Xbstream]
[Commands]
start_mysql_command=systemctl start mysql@default.service
stop_mysql_command=systemctl stop mysql@default.service
#Change user:group respectively
chown_command=chown -R mysql:mysql
icy1900 commented 2 years ago

I add some debug code print(str(self.mysql_options.get("data_dir"))) in copy_back.py,

    def move_to_tmp_dir(self) -> None:
        print(str(self.mysql_options.get("data_dir")))
        try:
            shutil.move(
                str(self.mysql_options.get("data_dir")),
                str(self.backup_options.get("tmp_dir")),
            )

and find out the print is

None

I thought it was due to there is no data_dir option in my.cnf but datadir, so I add a data_dir with same value as datadir, but get the same result.

icy1900 commented 2 years ago

I found 3 error in the script, and create a pull request https://github.com/ShahriyarR/MySQL-AutoXtraBackup/pull/456