How to delete redundant files in Google Drive when syncing from server?

I want to delete files that no longer exist on the drive, ie the file no longer exists on the main server but it was still on the Drive at the previous sync. What can I do?
This is the command I am using: rclone sync -i SOURCE remote:DESTINATION
i install aapanel on centos, i install with command curl https://rclone.org/install.sh | sudo bash, and dest is the google drive.
Thanks!!!

Not quite sure what you are asking.

If you sync, you make B an identical copy of A:

rclone sync A: B:

Anything in B would be deleted to match A.

This means that when I want to sync, files that are on Drive but don't exist on my server are automatically deleted. For example, on Drive there are files A, B, C but on my server there are only files A, B, then it automatically deletes file C

Rclone works on a source destination.

You can define or use it however you like but you need to figure out what use case makes sense for your setup.

While using sync, the destination will always match the source.

I use rclone sync -i but the file on the drive doesn't automatically delete when the file on the server doesn't exist. Am I using it wrong?

That's not a full command, nor any output so I don't know what you are running nor have you share any log / information.

The help and support template has all the required information. It's easiest to use that, fill it out and ask your question.

Quick example:

felix@gemini:~$ mkdir test1
felix@gemini:~$ cp /etc/hosts test1/testfile
felix@gemini:~$ rclone sync /home/felix/test /home/felix/test1 -vv
2021/11/19 13:54:49 DEBUG : Setting --config "/opt/rclone/rclone.conf" from environment variable RCLONE_CONFIG="/opt/rclone/rclone.conf"
2021/11/19 13:54:49 DEBUG : rclone: Version "v1.57.0" starting with parameters ["rclone" "sync" "/home/felix/test" "/home/felix/test1" "-vv"]
2021/11/19 13:54:49 DEBUG : Creating backend with remote "/home/felix/test"
2021/11/19 13:54:49 DEBUG : Using config file from "/opt/rclone/rclone.conf"
2021/11/19 13:54:49 DEBUG : Creating backend with remote "/home/felix/test1"
2021/11/19 13:54:49 DEBUG : Local file system at /home/felix/test1: Waiting for checks to finish
2021/11/19 13:54:49 DEBUG : Local file system at /home/felix/test1: Waiting for transfers to finish
2021/11/19 13:54:49 DEBUG : hosts: md5 = 5fa87111017bc9d656083774712d5334 OK
2021/11/19 13:54:49 INFO  : hosts: Copied (new)
2021/11/19 13:54:49 DEBUG : Waiting for deletions to finish
2021/11/19 13:54:49 INFO  : testfile: Deleted
2021/11/19 13:54:49 INFO  :
Transferred:   	        159 B / 159 B, 100%, 0 B/s, ETA -
Checks:                 1 / 1, 100%
Deleted:                1 (files), 0 (dirs)
Transferred:            1 / 1, 100%
Elapsed time:         0.0s

2021/11/19 13:54:49 DEBUG : 3 go routines active

Can you give me an example of your file sync command? I have a hard time understanding

Source - /home/felix/test
Destination /home/felix/test1

I just did a very simple test. I 1 file in the source. I had 1 extra file in the destination.

021/11/19 13:54:49 DEBUG : hosts: md5 = 5fa87111017bc9d656083774712d5334 OK
2021/11/19 13:54:49 INFO  : hosts: Copied (new)

This line shows the source get copied to my destination.

2021/11/19 13:54:49 DEBUG : Waiting for deletions to finish
2021/11/19 13:54:49 INFO  : testfile: Deleted

These lines show any 'extra' files got deleted.

If you want to test things with sync as it's destructive, please use --dry-run as that shows what will happen. There is (usually) no going back when you do destructive operations so please be careful.

Really thanks but I don't understand, I only need 1 command to run the sync!

I'm unsure how to assist as I've already shared 1 command, an example and completely explained the example.

Is it because I add -i, rclone sync -i A: B: that Google drive doesn't automatically match the server

  -i, --interactive                          Enable interactive mode

That means you have to enter input as the command progress.

felix@gemini:~$ rclone sync -i /home/felix/test /home/felix/test1
rclone: copy "hosts"?
y) Yes, this is OK (default)
n) No, skip this
s) Skip all copy operations with no more questions
!) Do all copy operations with no more questions
q) Exit rclone now.
y/n/s/!/q> y
rclone: delete "blah"?
y) Yes, this is OK (default)
n) No, skip this
s) Skip all delete operations with no more questions
!) Do all delete operations with no more questions
q) Exit rclone now.
y/n/s/!/q> y
2021/11/20 13:06:13 NOTICE:
Transferred:   	        159 B / 159 B, 100%, 31 B/s, ETA 0s
Checks:                 1 / 1, 100%
Deleted:                1 (files), 0 (dirs)
Transferred:            1 / 1, 100%
Elapsed time:         5.6s

If you hit "no", they would not match because you've told it not to match. The defaults are yes.

I pressed !, in this case what should I choose? Or simply leave out the -i

If you want to get assistance, make a new post, fill out the help and support template and provide all the details.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.