Maintain directory structure on Linux and move old files

Thing you want to do

I want to save old files to another directory. To the directory that mounts cheap storage.

Like this.

#Moving source
/home/hogehoge/aaa/file1  2019/12/24 Update ← Move this. old
                └  file2  2020/12/24 update ← This is as it is. new

#Destination
/cheep/backup/

here
/cheep/backup/aaa/file1
I want to be like this!

How to do

Use rsync.

cd /home/hogehoge
rsync --remove-source-files -t -p -R $(find ./ -type f -mtime +365) /cheep/backup/

There must be a better way. .. .. Someone tell me.

Recommended Posts

Maintain directory structure on Linux and move old files
Linux directory structure
Linux directory structure
Linux: files and directories
Linux (about files and directories)
About LINUX files and processes
Recording and playback on Linux
Linux file and directory permissions
[Linux] File and directory operation commands
Find large files / directories on Linux
[UE4] Build DedicatedServer on Windows and Linux
[Linux] How to subdivide files and folders
Find files like find on linux in Python
Install wsl2 and master linux on windows
Recursively get FTP directory on UNIX / LINUX
Install and launch k3s on Manjaro Linux
Install and Configure TigerVNC server on Linux
Learn sshd_config and authorized_keys (on Amazon Linux 2)
Replacing rmtrash on Mac and replacing rm on Linux
How to find large files on Linux
Organize files on Windows with Linux commands-using WSL-
Invert screen output vertically and horizontally on linux
Remove old pyenv environment on Mac and update
Rename and move files (directories) with mv command