Skip to content

How To View Messages & Photos Deleted by Your Friends on Viber Chat

It is just a single line of shell command, but it helped me solve a problem so I guess it deserves its own post. Forewarning: You cannot undelete what's already been deleted before implementing this method.

Anyway, I am on a Viber group which has a couple of friends from my college. My motivation towards this problem is one friend in particular, who sends photos (memes/embarrassing pics of other friends) and texts and deletes them in an instant. I missed out on these inside jokes many a times. So, I was brainstorming for possible solutions: my first solution was to write a script that would regularly monitor the ViberDownloads folder for changes and take backups to another directory (FYI, when a person sends a picture on Viber, it is first downloaded onto the ViberDownloads folder, and whenever the person deletes it from Viber, it is also deleted from ViberDownloads at the same time). The next solution hit home.

You might be familiar with chmod which is used to change permissions of files and directories. What I was looking for was an ability to change the permission of files/directory to append only. So that an user could only append to the file/directory but couldn't delete from it. I knew it was not possible with chmod, so I started looking around. I eventually found what I was looking for: chflags (change file flags).

There are several flags available for the chflags utility. Among them, the flag uappnd did exactly what I wanted to do: set the permission to append only. This utility works on Linux and MacOS. I am not sure how you'd go about doing the same on Windows.

Making folders/files append only

I installed Viber on my Mac. I was only using it on my cell phone earlier. Then, in order to make sure that the photos don't get deleted, I simply ran the following command on the terminal:

This meant when any of my contact sent me photos, they would be downloaded onto my ViberDownloads folder (on Mac the folder is inside Documents, and on Linux, I think it is on the home directory), and even after they deleted the photos, they would still remain on the same folder, because there's only append permission -- no delete permission at all.

Now the next challenge: what about the messages? how could I save them from getting deleted?

Well, I used SQLite browser and started looking at the .db files inside Viber's application folder and eventually found where the messages are stored. On Mac, the messages are stored at the following location:

I'm sure you can figure out the location for the file on Linux too.

Then it was just a matter of executing the same chflags utility on this SQLite database. However, once you run chflags on viber.db, the application on your Mac/Linux will no longer sync (or rather, will not display any new messages on your computer). Therefore, there's a sequence to be followed:

  • Step 1: Run chflags on the viber.db file (with Viber closed).

  • Step 2: Keep using Viber on your phone as you normally do.
  • Step 3: In order to make sure that the messages get downloaded onto your computer, even if they're not shown, make sure you open the application on your Mac/Linux from time to time. It seems like the viber.db file is the secondary file. The messages first get stored in some other file and then only they're moved to the viber.db file. So, keep using it on your phone but open the application on your computer too sometimes. In my case, it just runs on Startup so I don't have to bother with anything.
  • Step 4: If you wish to see the messages/photos that your friends had deleted just run the chflags utility with nouappnd flag to restore all the permissions (with Viber closed.)

  • Step 5: Open Viber, and you will see all the messages and photos, even the ones that you couldn't view on your cell phone because they were deleted.
  • Repeat from Step 1.

Das it, enjoy!

Published inHow To'sUseful Tools

2 Comments

  1. Umesh Dhungana Umesh Dhungana

    Wow!! Nice blog as always. It really helped me.

Leave a Reply

Your email address will not be published. Required fields are marked *