I am trying to write a python 3 script that will compress the contents of a directory /home/pi/results and copy it to another folder /home/pi/backups.
I need to be able to run this script multiple times and each time, the resulting archive is named something based on the previous archives. So first run would create backup001.tgz, second run would create backup002.tgz, etc. Each backup will be a complete backup containing anything within that directory.
I've figured out how to compress the folder to a .tgz, I just can't figure out how to append a number to it based on previous backups.
tar=tarfile.open(backupdir+'backup.tgz', "w:gz")
            tar.add(resultspath, arcname=os.path.basename(resultspath))
            tar.close()
 
     
     
     
     
     
    