Cfengine configuration directory

Remote methods for backup

Relevant classes: any

Suppose we want to make a backup of remote PCs using voluntary RPC.

On the laptop:

control:

 AddInstallable = ( BackupLapTop_done )

methods:

 Hr13|Hr14::

  BackupLapTop("/home/mark/LapTop","/dir/Backup",$(global.ipv4[eth0]))

  action=cf.laptopbackup
  server=backupserver.tld

  forcereplyto=10.11.7.66 # Laptop's IP address

  returnclasses=done
  returnvars=ret
  ifelapsed=240

On the server that will store the backup we need both an invitation:

methods:

 Hr13.backupserver::

  BackupLapTop("/home/mark/LapTop","/dir/Backup",$(global.ipv4[eth0]))

  action=cf.laptopbackup
  server=backupserver.tld
  returnclasses=done
  returnvars=ret
  ifelapsed=240

and the method itself:
control:

 MethodName       = ( BackupLapTop )
 MethodParameters = ( from to clientip )
 
 actionsequence   = ( copy )
 domain           = ( iu.hio.no )

####################################################

classes:

  moduleresult = ( any )
  done = ( any )

####################################################

 copy:

   $(from) dest=$(to) 
           server=$(clientip) 
           recurse=inf
           exclude=*.o
           owner=backup_user

####################################################

alerts:

 nexus::

   "Attempting backup of laptop $(date)"

 moduleresult::

  "LapTop Backup of $(clientip) on $(host) done"

  ReturnVariables("${host}")
  ReturnClasses(done)

 !moduleresult::

   "Backup failed at $(date)"

#  ReturnVariables("${host}")
#  ReturnClasses(notdone)

Back to documentation