I took a backup of a directory which has a number directories and files inside them. Recently some files have gone missing. I would like to just move over the missing files.
I prefer moving files instead of just copying as space is a premium on this particular box and the files are quite large.
How can i achieve this without a GUI and on the command line?
Personally, I find myself using rsync quite often for this kind of thing. Read the man page. There are a lot of options and it can be a lot to learn, but in the long run, I think that it will be worth it. The best part is that it is free and found already installed on most Linux systems.
Amongst rsync's options include updating only the files that have changed since the last update, ability to filter certain files and directories, you can do a dry-run first, and many many other features. Notably, rsync can copy not only between files on the host system, but even over a network. So, however you have backed up your files, it should work. A quick look at the man page seems that the --remove-source-files option would be similar to moving the files. You may even find that you like it enough to use it to do your backup next time.
The quick and dirty way is to us the mv (move) command with the -n or --no-clobber option.
From the mv man page:
Example:
You two directories:
/files/
/backup/
if /files is the original directory that is missing the files and the /backup directory is your most current backup, the command would be:
mv -n /backup/* /files
If your version of Linux/Unix does not support the -n option you can do the same thing with the -i option, except it will ask if you want to overwrite the existing file. You will need to answer no each file. It will not ask you if the file does not exist in the destination directory.
From the mv man page:
i.e. mv -i /backup/* /files
Be careful.
JimT
Do a folder comparison using the trial version of Beyond Compare, then move the files right in there. Easy.
Similar to the answer from JimT:
where "/backupdir" is your backup directory and "/origdir" your original source dir.
The "yes" command is very useful for handling interactive commands. In this case it automatically answers "no" to the prompt when asked to overwrite existing files, so only the files that are missing will be moved.