Jumat, 10 Mei 2013

Copy Folder di Linux

Bingung pas pindahin data di linux tanpa xwindow?? itu lah yang dialami pass migrasi dari ubuntu biasa ke server yang ga punya xwindow, yang biasa tinggal copy paste eh sekarang jadi bingung karena tampilannya yang hitam semua :)

nah ini cara untuk copy folde di linux :

Untuk mengcopy sebuah folder, anda perlu menambahkan parameter -r (melakukan copy direktori secara recursive), sehingga commandnya menjadi:
cp -r /home/azhar/folder_awal /home/azhar/folder_tujuan/


Copy dengan Parameter Lain

Parameter lain yang dapat digunakan juga misalnya adalah:
-a melakukan copy dengan mempertahankan owner, timestamps, dl
-v menampilkan penjelasan dari proses copy yang dilakukan
Contoh:
cp -avr /home/azhar/folder_awal /home/azhar/folder_tujuan/
atau dari sumber lain :

cp Command

cp is a Linux command for copying files and directories. The syntax is as follows:
 
cp source destination
cp dir1 dir2
cp -option  source destination
cp -option1 -option2  source destination
 
In this example copy /home/vivek/letters folder and all its files to /usb/backup directory:
 
cp -avr /home/vivek/letters /usb/backup
 
Where,
  • -a : Preserve the specified attributes such as directory an file mode, ownership, timestamps, if possible additional attributes: context, links, xattr, all.
  • -v : Explain what is being done.
  • -r : Copy directories recursively.

Example

Copy a folder called /tmp/conf to /tmp/backup:
$ cp -avr /tmp/conf/ /tmp/backup
Sample outputs:
HowTO: Copy Folder Linux Terminal Command
Fig.01: cp command in action

rsync Command

You can also use rsync command which is a fast and extraordinarily versatile file copying tool. It can make copies across the network. The syntax is as follows:
 
rsync -av /path/to/source /path/to/destination
rsync -av /path/to/source/ /path/to/destination/source
 
To backup my home directory, which consists of large files and mail folders to /media/backup, enter:
$ rsync -avz /home/vivek /media/backup
I can copy a folder to remote machine called server1.cyberciti.biz:
$ rsync -avz /home/vivek/ server1.cyberciti.biz:/home/backups/vivek
Where,
  • -a : Archive mode i.e. copy a folder with all its permission and other information including recursive copy.
  • -v : Verbose mode.
  • -z : With this option, rsync compresses the file data as it is sent to the destination machine, which reduces the amount of data being transmitted — something that is useful over a slow connection.
You can show progress during transfer using --progress or -P option:
$ rsync -av --progress /path/to/source/ /path/to/dest
Sample outputs:
Copy Folder Linux Commands [ rsync ]

Tidak ada komentar: