I want to create a batch file that backup our postgresql database schema. But I also want it to look in the backup folder how many files there are. If there are already 4 backup files, I want the batch file to delete 1. So the maximum of backup files has to be 4.
Below you find the code that I already have. I works, but I want to add that there can only be a maximum of 4 backupfiles.
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
echo datestr is %datestr%
echo backup file name is %BACKUP_FILE%
postgres\bin\pg_dump -i -h localhost -p 5432 -U postgres -F c -v -f %BACKUP_FILE% -n archx archx