Jump to content

moving files with command line


Tyro

Recommended Posts

I wanted to make a bash script that would backup a dir, then move the backup to a deferent hdd for safekeeping.Did that all ok - borrowed and adjusted one from http://www.linuxplanet.com/linuxplanet/tutorials/5257/3/ Then I added the following to the end. mv -fv /home/steve/1backups/backup*.* /mnt/hdb3/steve/This works fine where a backup file is moved from hda6 to hdb3 as expected. But if i try to move the same file across the network to a windows machine - mv -fv /home/steve/1backups/backup*.* smb://downstairs/SharedDocs/It comes up with this error - mv: cannot move `/home/steve/1backups/backup-20050101.tgz' to `smb://downstairs/SharedDocs/backup-20050101.tgz': No such file or directoryI presume this is because of smb. :angry: Can anyone tell me how to do this correctly?Tyro :-)

Link to comment
Share on other sites

Hmm,if you use the mv command and then use the mv command again on the same file(s) then you should get an error message because those files are no longer where they were originally since you just moved them. If you used cp for copy then you could use mv as the second command or use cp again. The other alternative is to adjust the second mv command to use as its source, the destination of the original command. I'm assuming that's what you did, to get the error message. :angry:

Link to comment
Share on other sites

No you missunderstand, What I meant was If I use the line mv -fv /home/steve/1backups/backup*.* smb://downstairs/SharedDocs/ (this should move the file across the network) I get an error. :angry: Instead of - mv -fv /home/steve/1backups/backup*.* /mnt/hdb3/steve/ ( this moves the file between harddrives) where this works ok.I would prefer to move the file across the network as this would be safer as a backup. Tyro :-)

Link to comment
Share on other sites

I've never tried it but I don't think mv recognizes things like smb:// or ftp:// etc. It's not that smart; it's only for drives. What you'd have to do is mount the remote Samba drive using smbmount in a /mnt/ location (or wherever you like) and then mv the file. Does that make sense?

Link to comment
Share on other sites

You may have to play with this in a script. Doing it manually, I mounted the shared directory using this syntax:

mount -t smbfs -o rw,username=ebrke //netbios-name/share-name /existing-mnt-point
You're going to have to play around with ownership issues if you want to move rather than copy, but I was able to do it successfully after mounting the Samba share. Also, I'm going linux to linux rather than linux to windows, same owner issues may not exist going to a windows share, I don't know. Edited by ebrke
Link to comment
Share on other sites

No you missunderstand, What I meant was If I use the line mv -fv /home/steve/1backups/backup*.* smb://downstairs/SharedDocs/  (this should move the file across the network)  I get an error. :D  Instead of  - mv -fv /home/steve/1backups/backup*.* /mnt/hdb3/steve/        ( this moves the file between harddrives)  where this works ok. I would prefer to move the file across the network  as this would be safer as a backup.  Tyro :-)
ok i must of read this at least 5x and still dont know what you mean and why you would try to use mv to do that whats the matter with rsync command especially when it comes to do that job anyway i think you should check this outalso man rsync only way i know
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...