Copy a directory tree preserving metadata
Preserve mode, ownership, timestamps, and symlinks.
cp -a /src/. /dst/Preserve mode, ownership, timestamps, and symlinks.
Backup, copy, imaging, clone, and storage troubleshooting workflows on Linux.
Copy, archive, and sync data efficiently.
Preserve mode, ownership, timestamps, and symlinks.
cp -a /src/. /dst/Preserve mode, ownership, timestamps, and symlinks.
Powerful local or remote copy preserving metadata and ACLs when supported.
rsync -aHAX --info=progress2 /src/ /dst/Powerful local or remote copy preserving metadata and ACLs when supported.
Make the destination match the source exactly.
rsync -a --delete /src/ /dst/Make the destination match the source exactly.
rsync -aP /src/ user@host:/backup/Efficiently transfer deltas to a remote server.
tar -czf backup.tar.gz /dataPackage and compress a directory tree.
tar -xzf backup.tar.gz -C /restoreRestore archive contents to a target directory.
tar -tf backup.tar.gzInspect what an archive contains before extracting.
Useful in some initramfs and recovery workflows.
find . -print | cpio -ov > archive.cpioUseful in some initramfs and recovery workflows.
Add transfer progress to streaming backup pipelines.
tar -cf - /data | pv | gzip > backup.tar.gzAdd transfer progress to streaming backup pipelines.
Record integrity hashes for backup artifacts.
sha256sum backup.tar.gz > backup.tar.gz.sha256Record integrity hashes for backup artifacts.
Create raw images and clone or restore devices.
sudo dd if=/dev/sdb of=disk.img bs=64K status=progress conv=sync,noerrorImage a disk device to a raw file.
sudo dd if=disk.img of=/dev/sdb bs=64K status=progress conv=fsyncRestore a disk image onto a target device.
Preferred over dd for failing disks because it tracks progress and retries.
sudo ddrescue -f -n /dev/sdb disk.img disk.logPreferred over dd for failing disks because it tracks progress and retries.
Save GPT headers and partition entries to a file.
sudo sgdisk --backup=gpt.backup /dev/sdbSave GPT headers and partition entries to a file.
Restore GPT layout from a saved backup file.
sudo sgdisk --load-backup=gpt.backup /dev/sdbRestore GPT layout from a saved backup file.
Show image format, virtual size, and backing file info.
qemu-img info disk.qcow2Show image format, virtual size, and backing file info.
Convert between raw, qcow2, and other image formats.
qemu-img convert -O qcow2 disk.raw disk.qcow2Convert between raw, qcow2, and other image formats.
Compress large raw images for storage or transfer.
gzip -1 disk.imgCompress large raw images for storage or transfer.
xz -T0 disk.imgUse stronger compression for cold storage backups.
Quick equality check for cloned images of the same size.
cmp disk1.img disk2.imgQuick equality check for cloned images of the same size.
Find hot paths, busy mounts, and performance or capacity problems.
Inspect per-device read/write rates and utilization over time.
iostat -xz 1Inspect per-device read/write rates and utilization over time.
Find which processes generate the most disk I/O.
sudo iotopFind which processes generate the most disk I/O.
Track read/write activity by process over time.
pidstat -d 1Track read/write activity by process over time.
Quick check for iowait, swap, and block device pressure.
vmstat 1Quick check for iowait, swap, and block device pressure.
Look for hardware and filesystem errors in kernel logs.
dmesg | egrep -i 'sd[a-z]|nvme|md|I/O error|ext4|xfs'Look for hardware and filesystem errors in kernel logs.
Kernel journal view for storage-related problems.
journalctl -k | egrep -i 'I/O error|blk_update_request|nvme|md'Kernel journal view for storage-related problems.
Find large paths interactively with a terminal UI.
sudo ncdu /Find large paths interactively with a terminal UI.
find /var -xdev -type f -size +1G -printf '%s %p
' | sort -nLocate unexpectedly large files on a filesystem.
Useful when df is full but du cannot explain it.
sudo lsof | grep '(deleted)'Useful when df is full but du cannot explain it.
Discard unused blocks on mounted SSD-backed filesystems.
sudo fstrim -avDiscard unused blocks on mounted SSD-backed filesystems.