File-based Backup

This solution is applicable to the following scenarios:

  • EVS snapshots cannot meet your requirements.
  • The system uses SFS file systems.
  • When a few files are changed, you want to back up the changed files only.

For file-based backups, run the tar, cpio, rsync, and scp commands to compress, copy, and transfer directories or files.

For details about how to fully back up the SAP system, see Backing Up and Restoring your SAP System on UNIX.

Run the tar command to back up all important files in the root directory to the /backup directory.

  • Backup Example
    #!/bin/sh
    
    echo "start to backup files.."
    
    mkdir -p /backup
    export backup_host=`hostname`
    export backup_date=`date +%Y-%m-%d`
    export backup_dir=/backup
    export backup_exclude_file=$backup_dir/backup-exclude-files.txt 
    export backup_file=$backup_dir/backup-$backup_host-$backup_date.tar.gz 
    export log_file=$backup_dir/backup.log
    export logerr_file=$backup_dir/backup.log.err
    
    #exclude dirs
    >$backup_exclude_file 
    echo "/tmp" >>$backup_exclude_file 
    echo "/sys" >>$backup_exclude_file 
    echo "/dev" >>$backup_exclude_file 
    echo "/proc" >>$backup_exclude_file 
    
    cd /backup 
    tar -zcvf $backup_file / --exclude-from=$backup_exclude_file >$log_file 2>$logerr_file 
    
    echo "backup finished." 
    echo "backup file to:" $backup_file
  • Restoration Example
    tar -zxvf backup-prdpas-2019-06-28.tar.gz -C /  >recovery.log 2>recovery.log.err

If you need to back up directories or files separately, modify the backup script in the preceding example. Use the obsutil tool and others alike provided by the HUAWEI CLOUD to periodically transfer the backup files to OBS buckets.