2

I am trying to upload files from a folder on my machine onto s3 and delete the file from my local machine after the upload is complete.

I have a cron running every minute with this command, but it isn't working:

s3cmd sync -r --delete-after /home/username/Videos/* s3://bucketname

whats wrong with this? I can upload using s3cmd sync so the config isn't wrong - but the delete after command doesn't seem to work.

helptomout
  • 195
  • 4
  • 9

3 Answers3

1

--delete-after is used to delete removed files at the destination after uploading the new files. It lets remote trees stay consistent until the uploads of new content are complete. It does not delete files from the source.

Matt Domsch
  • 486
  • 2
  • 5
0

For my solution in bash I used s3cmd put with find (variation of https://stackoverflow.com/a/8489394) as following:

find /home/username/Videos -type f | while read -r FILE; do
  s3cmd put "$FILE" s3://bucketname
  if [ $? -eq 0 ]; then
    rm -f "$FILE" && echo "Successfully uploaded file:$FILE"
  else
    echo "ERROR Failed to upload file:${FILE}" && exit 42
  fi
done

Further note, that there's an open feature request at the s3tools repository one could up vote: https://github.com/s3tools/s3cmd/issues/262

nickma
  • 1
  • 3
-1

You need to write bash file, and have to remove local machine file by linux rm command,add these commands in bashfile and setup cronjob. Sync_delete_local_file.sh

s3cmd sync setacl --acl-public --recursive --preserve --skip-existing /home/username/Videos/ s3://bucketname

rm -r /home/username/Videos/*
Jackson Harry
  • 308
  • 1
  • 2
  • 15