1829399 Members
1689 Online
109991 Solutions
New Discussion

mv command help

 
SOLVED
Go to solution
noe
Occasional Advisor

mv command help

hello all,
im doing a daily refresh of my database to a backup location. the database has subdirectories.so this is the command im using

mv /DATA/* /BACKUP
the error is:
subdir in DATA/subdir already exist
my question:
how can i create a script that will move and overwrite the BACKUP dir and SUBDIR with the refreshed data that i move daily?
thanks all in advance
5 REPLIES 5
Steven Schweda
Honored Contributor

Re: mv command help

"tar" pipeline?
OldSchool
Honored Contributor

Re: mv command help

well, is it safe to remove /BACKUP entirely before you do the move?

as in:
rm -rf /BACKUP
mv /DATA/* /BACKUP

or

if not, then find the directories immediately under /DATA, and using that information, remove the same from the /BACKUP directory, then do the move.

there are probably 1/2 a dozen other ways to do this as well...man tar has a couple of examples that might be enlightening
Vishu
Trusted Contributor
Solution

Re: mv command help

Hi Noe,

1. you can remove the Backup folder and create it again for backup.

2. As you do it on daily basis, so you can make directory under /BACKUP with the name "backup. and save DATA in it

3. you can use Tar to group all the files into a single file in /BACKUP folder.
Victor Fridyev
Honored Contributor

Re: mv command help

cd /DATA; tar cf - *|(cd /BACKUP; tar xf - )
cd /; rm -r /DATA

HTH
Entities are not to be multiplied beyond necessity - RTFM
noe
Occasional Advisor

Re: mv command help

thank you