Labels

Backup commandline in linux

# find /var/log -name '*.log' | tar cv --files-from=- | bzip2 > log.tar.bz2
find all files with '.log' extention and make an bzip archive [man]

# find /home/user1 -name '*.txt' | xargs cp -av --target-directory=/home/backup/ --parents
find and copy all files with '.txt' extention from a directory to another [man]

# dd bs=1M if=/dev/hda | gzip | ssh user@ip_addr 'dd of=hda.gz'
make a backup of a local hard disk on remote host via ssh [man]

# dd if=/dev/sda of=/tmp/file1
backup content of the harddrive to a file [man]

# dd if=/dev/hda of=/dev/fd0 bs=512 count=1
make a copy of MBR (Master Boot Record) to floppy [man]

# dd if=/dev/fd0 of=/dev/hda bs=512 count=1
restore MBR from backup copy saved to floppy [man]

# dump -0aj -f /tmp/home0.bak /home
make a full backup of directory '/home' [man]

# dump -1aj -f /tmp/home0.bak /home
make a incremental backup of directory '/home' [man]

# restore -if /tmp/home0.bak
restoring a backup interactively [man]

# rsync -rogpav --delete /home /tmp
synchronization between directories [man]

# rsync -rogpav -e ssh --delete /home ip_address:/tmp
rsync via SSH tunnel [man]

# rsync -az -e ssh --delete ip_addr:/home/public /home/local
synchronize a local directory with a remote directory via ssh and compression [man]

# rsync -az -e ssh --delete /home/local ip_addr:/home/public
synchronize a remote directory with a local directory via ssh and compression [man]

# tar -Puf backup.tar /home/user
make a incremental backup of directory '/home/user' [man]

# ( cd /tmp/local/ && tar c . ) | ssh -C user@ip_addr 'cd /home/share/ && tar x -p'
copy content of a directory on remote directory via ssh [man]

# ( tar c /home ) | ssh -C user@ip_addr 'cd /home/backup-home && tar x -p'
copy a local directory on remote directory via ssh [man]