How to backup a directory in Linux

backup
centos7

#1

I need to backup a directory named /var/www/html/ in Centos Linux version 7. I need to backup folder to /dev/sdb1 mounted at /disk2/ and USB pen mounted /mnt/external_usb_pen. What is the best way to backup a directory or folder in Linux?


#2

You can use any one of the following tool:

  1. rsync
  2. tar
  3. pax and more

Use rsync command to backup a folder in Linux

Backup /var/www/html/ to /disk2/

rsync -avr /var/www/html/ /disk2/
rsync -avr /var/www/html/  /mnt/external_usb_pen/

You can backup to remote server as well:

rsync -avr /var/www/html/ user@server-name:/path/to/backup/dir/here/

See:


And:

Use tar to backup a directory in Linux

tar -zcvf /disk2/backup.tar.gz /var/www/html/

See the following for more info: