Пример #1
0
# cronjob script to backup to USB sticks (need to be user-mountable)

from os import system, path
import rsyncbackup as rb
targets = [
  '/backupstick',
  '/backupstick_sony',
  '/backupstick_sandisk',
  '/backupstick_usbplatte',
  '/backupstick_sony2',
]
success = 0
for target in targets:
  system('mount ' + target + ' 2>/dev/null')
  if not path.isdir(target + '/lost+found'):
    continue
  try:
    rb.backup('/home/martin/', target + '/martin')
  finally:
    system('sync')
  success += 1

assert success > 0, 'No USB sticks plugged in for backup!'

Пример #2
0
#!/usr/bin/env python
import rsyncbackup

# backup(src='rsync path', dst='local directory')
# ping before starting avoids rsync error if host is down
rsyncbackup.backup('wanze:/', '/backup-wanze')
rsyncbackup.backup('nordfenster:/', '/backup-nordfenster', ping='nordfenster')

Пример #3
0
#!/usr/bin/env python
import rsyncbackup

# basic rsync command and flags
rsync = 'rsync -az --delete-excluded --exclude-from=excludes'
rsync += ' -e "ssh -i /home/martin/.ssh/id_dsa_netbackup"'

rsyncbackup.rsync = rsync

# backup(src='rsync path', dst='local directory')
# ping before starting avoids rsync error if host is down
rsyncbackup.backup('bazaar:/home/martin/', '/home/martin/backup-bazaar')
Пример #4
0
# cronjob script to backup to USB sticks (need to be user-mountable)

from os import system, path
import rsyncbackup as rb

targets = [
    '/backupstick',
    '/backupstick_sony',
    '/backupstick_sandisk',
    '/backupstick_usbplatte',
    '/backupstick_sony2',
]
success = 0
for target in targets:
    system('mount ' + target + ' 2>/dev/null')
    if not path.isdir(target + '/lost+found'):
        continue
    try:
        rb.backup('/home/martin/', target + '/martin')
    finally:
        system('sync')
    success += 1

assert success > 0, 'No USB sticks plugged in for backup!'
Пример #5
0
#!/usr/bin/env python
import rsyncbackup

# basic rsync command and flags
rsync = "rsync -az --delete-excluded --exclude-from=excludes"
rsync += ' -e "ssh -i /home/martin/.ssh/id_dsa_netbackup"'

rsyncbackup.rsync = rsync

# backup(src='rsync path', dst='local directory')
# ping before starting avoids rsync error if host is down
rsyncbackup.backup("bazaar:/home/martin/", "/home/martin/backup-bazaar")