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.
mkfs.xfs -f -L 'boot' -m uuid='002d5b26-a897-4f33-a93f-8f083cca7cc3' '/dev/vdb2'
mkdir -v /tmp/src
mkdir -v /tmp/dest
mount -v -t xfs -o noatime,ro '/dev/vda2' '/tmp/src'
mount -v -t xfs -o nouuid '/dev/vdb2' '/tmp/dest'
sh -c 'xfsdump -J - '\''/tmp/src'\'' | xfsrestore -J - '\''/tmp/dest'\'''
umount -v '/tmp/dest'
umount -v '/tmp/src'
rmdir -v /tmp/dest
rmdir -v /tmp/src
xfs_repair -v '/dev/vdb2'
Backup #
Creating a backup with xfsdump
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
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.
xfsdump -L sess1 -M wp -f /root/wp.xfs -z 10M /mnt/main
Copy filesystem to another directory
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
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 - undeletable
Untuk attribute pada file atau folder saat ini.
lsattr
Selanjutnya backup XFS dengan perintah
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.
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
xfsrestore -t -f /mnt/backup/wp.xfs
Restoring a full backup
xfsrestore -f /mnt/backup/wp.xfs /var/www/
Prevents overwriting existing files
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
xfs_repair /dev/vdb