move backup logic to lib. Fixed removing outdated backups