Automatically rename backup (build history)

The following script ensures that the backup you created is renamed nine times before it is deleted.

The following batch file consists of two parts:

  • In the first part the batch file renames a backup nine times (if required).
  • In the second (optional) part the batch file copies the backup to another location.

Start using script:

  1. Copy the following script to a batch file.
  2. Enter the path and the location of the log file on the 'SET logfile=' line.
  3. Enter the location of the backups on the 'SET backuppath=' line.
  4. Change DBNAAM to the backup name of your database.
  5. Correctly set up the AFASCMD.EXE command line.

    With this approach you must not include the date and time in the name of the backup, otherwise the renaming no longer works. The name of the backup created by the command line must always be the same.

  6. Delete the REM statement for the relevant lines in part 2 if you want to use this.
  7. Enter the location of the backup server on the 'SET backupserver=' line.

    Example: 

    @Echo off

    REM DEEL 1: BESTANDEN HERNOEMEN

    REM

    SET logfile="D:\Profit\AFAS Backup\AfasBackup.log"

    SET backuppath="D:\Profit\AFAS Backup"

    REM

    echo Start backup Afas >> %logfile%

    REM

    date /t >> %logfile%

    time /t >> %logfile%

    REM

    REM Start copy backup files

    REM

    IF Exist %backuppath%\DBNAAM09.* del %backuppath%\DBNAAM09.*

    IF Exist %backuppath%\DBNAAM08.* ren %backuppath%\DBNAAM08.* DBNAAM09.*

    IF Exist %backuppath%\DBNAAM07.* ren %backuppath%\DBNAAM07.* DBNAAM08.*

    IF Exist %backuppath%\DBNAAM06.* ren %backuppath%\DBNAAM06.* DBNAAM07.*

    IF Exist %backuppath%\DBNAAM05.* ren %backuppath%\DBNAAM05.* DBNAAM06.*

    IF Exist %backuppath%\DBNAAM04.* ren %backuppath%\DBNAAM04.* DBNAAM05.*

    IF Exist %backuppath%\DBNAAM03.* ren %backuppath%\DBNAAM03.* DBNAAM04.*

    IF Exist %backuppath%\DBNAAM02.* ren %backuppath%\DBNAAM02.* DBNAAM03.*

    IF Exist %backuppath%\DBNAAM01.* ren %backuppath%\DBNAAM01.* DBNAAM02.*

    IF Exist %backuppath%\DBNAAM.* ren %backuppath%\DBNAAM.* DBNAAM01.*

    REM

    Echo Start Creating new backup file >> %logfile%

    REM

    "C:\Program files (x86)\Profit\AFAS Windows\Kernel\Bin\AFASCMD.EXE"/O"DatabaseNaam" /G"BackupUser" Backup /L%logfile%

    REM

    echo End backup Afas >> %logfile%

    REM PART 2: COPY FILE TO OTHER LOCATION

    SET backupserver=

    REM

    REM Echo Start copy to other side >> %logfile%

    REM

    REM copy %backuppath%\DBNAAM.ZIP %backupserver% >> %logfile%

Directly to

  1. Make and restore backups (Command Line Utility)
  2. Backup guidelines per authentication method
  3. Create a backup
  4. Automatically rename a backup (build history)
  5. Restore a backup
  6. Split backup of files and database