hello and welcome to the forum,
i use python to script rclone, 7zip, veeam, fastcopy and VSS.
the script creates the commands and runs them using subprocess.run
i find subprocess.run
the most flexible way to run rclone, as it can also run any command.
the script reads the particular backup details from an .ini entry.
[en08_wasabi01_veeam_br_en08]
SourceDir=v:\BR_VSERVER03_EN08
DestDirRclone=wasabi_vserver03brvserver03en08:
DoVShadow=true
DoRcloneCopyFiles=--immutable --stats=5h --fast-list --bind=192.168.62.233 --include="*.{vib,vbk}" --max-age=30d --s3-no-check-bucket=true
DoProcessLogs=true
DoSendEmailLogs=true
RcloneUseArchiveDir=true
RcloneConfigFile=wasabi.conf
#RcloneDryRun=true
#DebugMode=true
the script take that .ini entry and creates the commands, for example.
RcloneCopyFilesCmd=C:\data\rclone\scripts\rclone.exe copy "B:\rclone\vss\en08_wasabi01_veeam_br_en08_20220310.092204\BR_VSERVER03_EN08" "wasabi_vserver03brvserver03en08:/en08/rclone/backup" --immutable --stats=5h --fast-list --bind=192.168.62.233 --include="*.{vib,vbk}" --max-age=30d --s3-no-check-bucket=true --log-level=DEBUG --log-file=C:\data\rclone\logs\en08_wasabi01_veeam_br_en08\20220310.092204\rclone.log --config=C:\data\rclone\scripts\rclone.conf --ask-password
and the function that runs them
def DoCmd(self, Text, Cmd, Input='', Env=''):
Common.Log(self, f'Start DoCmd {Text}={Cmd}')
if Common.DebugMode:
Common.Log(self, f'DebugMode: DoCmd: {Text}={Cmd}')
return
try:
the_env = {}; the_env = dict(os.environ)
if Env != '': the_env.update(Env)
x=subprocess.run(Cmd, cwd=Common.ScriptsDir, capture_output=True, text=True, input=Input, env=the_env)
if len(x.stdout) != 0:
xfile = open(f'{Common.BackupLogDir}\\{Text}.stdout.log', "w"); xfile.write(x.stdout); xfile.close()
if len(x.stderr) != 0:
xfile = open(f'{Common.BackupLogDir}\\{Text}.stderr.log', "w"); xfile.write(x.stderr); xfile.close()
if x.returncode==0:
Common.Log(self, f'DoCmd: End: {Text}={Cmd}')
return x
else:
Common.DoEnd(self, f'DoCmd: End ERROR: {Text}={Cmd} with returncode={x.returncode}')
except Exception as exception:
txt=f'DoCmd={Cmd} - {traceback.format_exc()}'
print(txt)
Common.DoEnd(self, txt)