Dengan utilitas xfsdump dan xfsrestore Anda dapat mencadangkan dan memulihkan file dalam filesystem XFS. Untuk mencadangkan file dapat Anda lakukan pada hard drive yang terpasang secara langsung atau ke tujuan hard drive jarak jauh yang dapat Anda akses melalui jaringan.
Lalu Anda juga dapat memulihkan data ke lokasi aslinya atau ke lokasi lain pada filesystem XFS.
Contoh untuk backup dan restore partisi boot secara langsung.
1
sh -c 'xfsdump -J - '\''/boot'\'' | xfsrestore -J - '\''/mnt/backup'\'''
Backup
Creating a backup with xfsdump
1
xfsdump -L session1 -M boot -f /mnt/backup/boot.xfs /boot
Perintah backup diatas merupakan backup level 0 dimana menyertakan keseluruhan file di filesystem
Creating incremental backups
Incremental backup hanya mencakup perubahan yang terjadi sejak backup sebelumnya (full atau incremental) dilakukan
1
xfsdump -l 1 -L session2 -M boot -f /mnt/backup/boot.xfs /boot
opsi -l digunakan untuk menentukan level backup (0-9). Jika tidak ditentukan maka secara default backup level 0 akan dilakukan.
Excluding files bigger than a specific size
Gunakan opsi -z untuk mengecualikan file dengan size tertentu.
1
xfsdump -L sess1 -M wp -f /root/wp.xfs -z 10M /mnt/main
Copy filesystem to another directory
1
xfsdump -J - / | xfsrestore -J - /new
Excluding arbitrary files
Untuk mengecualikan file atau folder yang tidak ingin dibackup atau didump.
Ubah attribute file atau folder dengan chattr
1
chattr -RV +ad wp-content
List attribute yang dapat Anda gunakan selain d atau no dump.
a - append only
A - no atime updates
c - compressed
C - no copy on write
d - no dump
D - synchronous directory updates
e - extent format
i - immutable
j - data journalling
s - secure deletion
S - synchronous updates
t - no tail-merging
T - top of directory hierarchy
u - undeletableUntuk attribute pada file atau folder saat ini.
1
lsattr
Selanjutnya backup XFS dengan perintah
1
xfsdump -L sess1 -M wp -e -f /mnt/backup/wp.xfs /var/www
Including only files in a specific directory
Gunakan untuk backup file atau direktori tertentu.
1
xfsdump -L sess1 -M wp -s wp-content -f /mnt/wp.xfs /var/www
Restore
Listing the content of a backup
Sebelum melakukan restore, Anda dapat melakukan pengecekan file backup menggunakan perintah berikut
1
xfsrestore -t -f /mnt/backup/wp.xfs
Restoring a full backup
1
xfsrestore -f /mnt/backup/wp.xfs /var/www/
Prevents overwriting existing files
1
xfsrestore -e -f /mnt/backup/wp.xfs /var/www/
File system check
Bagian ini opsional dan dapat dilewati. Namun jika Anda selesai restore filesystems XFS seperti partisi root / sebaiknya lakukan proses xfs repair agar
terhindar dari kerusakan data atau corrupt
1
xfs_repair /dev/vdb