Hi,
I am trying this batch file to backup my database but it is not creating the backup, when I tested it manually
Not sure why.
TIA
I am trying this batch file to backup my database but it is not creating the backup, when I tested it manually
Code:
@echo off
REM Set the path to your Access database
set dbPath=C:\Dailyreport\CurrentDB.accdb
REM Set the path to the backup folder
set backupFolder=W:\common\Reports\dbbackup
REM Get the current date and time
for /f "tokens=1-4 delims=/ " %%a in
("%date%") do (
set day=%%a
set month=%%b
set year=%%c
)
for /f "tokens=1-2 delims=:" %%a in
("%time%") do (
set hour=%%a set minute=%%b
)
REM Format the date and time (e.g., YYYYMMDD_HHMM)
set formattedDate=%year%%month%%day%
set formattedTime=%hour%%minute%
REM Create the backup file name
set backupFile=%backupFolder%\CurrentDB_backup_%formattedDate%_%formattedTime%.accdb
REM Perform the backup
copy "%dbPath%" "%backupFile%"
echo Backup completed successfully:
%backupFile%
Not sure why.
TIA