When archiving files with this simple script, all files that have Cyrillic in the name change the encoding and become unreadable.

import tarfile import os import datetime DATE = datetime.datetime.now().strftime('%Y-%m-%d') # filename for tar archive bak- output_filename = r"C:\py\to_backup\bak-" + DATE + ".tar.gz" # directory with file for backup source_dir = r"C:\py\from_backup" # path for backup bak_dir = r"C:\py\to_backup" def make_tarfile(output_filename, source_dir): tar = tarfile.open(output_filename, "w:gz") tar.add(source_dir, arcname=os.path.basename(source_dir)); tar.close() 

    1 answer 1

    Understood, it was necessary to add the encoding parameter,

     archive_encoding = 'cp1251' tar = tarfile.open(output_filename, "w:gz", encoding=archive_encoding)