Friday, February 28, 2014

easy learn linux command line-part 22

If you didnt know what is Back Up?!!! Please read here first.

there are many ways for create Back Up File in the operation systems. You can Use software or use default tools in your OS. its depends on you but i prefer default tools because i think my Linux OS is very Powerful and has many Options.

if you are agree with me, read this post please.

Today, We learn how to Create your Favorite (yes favorite, because you have many options) Back Up. and learn how to get back up From other formats like: TXT, Directories and etc.

after get  Back Up, you need to move it to other partitions or removable card and even or CD, DVD, online Hard Dirve, Cloud Storages.

Backup

Command Description
# find /var/log -name '*.log' | tar cv --files-from=- | bzip2 > log.tar.bz2 find all files with '.log' extention and make an bzip archive   
# 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   
# 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  
# dd if=/dev/sda of=/tmp/file1 backup content of the harddrive to a file  
# dd if=/dev/hda of=/dev/fd0 bs=512 count=1 make a copy of MBR (Master Boot Record) to floppy   
# dd if=/dev/fd0 of=/dev/hda bs=512 count=1 restore MBR from backup copy saved to floppy   
# dump -0aj -f /tmp/home0.bak /home make a full backup of directory '/home'   
# dump -1aj -f /tmp/home0.bak /home make a incremental backup of directory '/home'   
# restore -if /tmp/home0.bak restoring a backup interactively   
# rsync -rogpav --delete /home /tmp synchronization between directories   
# rsync -rogpav -e ssh --delete /home ip_address:/tmp rsync via SSH tunnel   
# rsync -az -e ssh --delete ip_addr:/home/public /home/local synchronize a local directory with a remote directory via ssh and compression   
# rsync -az -e ssh --delete /home/local ip_addr:/home/public synchronize a remote directory with a local directory via ssh and compression  
# tar -Puf backup.tar /home/user make a incremental backup of directory '/home/user'   
# ( 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   
# ( tar c /home ) | ssh -C user@ip_addr 'cd /home/backup-home && tar x -p' copy a local directory on remote directory via ssh   
# tar cf - . | (cd /tmp/backup ; tar xf - ) local copy preserving permits and links from a directory to another   

No comments: